removed templates from main
This commit is contained in:
		
							
								
								
									
										1
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								go.mod
									
									
									
									
									
								
							| @@ -6,6 +6,7 @@ require ( | |||||||
| 	gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a // indirect | 	gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a // indirect | ||||||
| 	gitea.elara.ws/Hazel/words v1.0.5 // indirect | 	gitea.elara.ws/Hazel/words v1.0.5 // indirect | ||||||
| 	github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 // indirect | 	github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 // indirect | ||||||
|  | 	github.com/gorilla/websocket v1.5.3 // indirect | ||||||
| 	github.com/labstack/echo/v4 v4.13.4 // indirect | 	github.com/labstack/echo/v4 v4.13.4 // indirect | ||||||
| 	github.com/labstack/gommon v0.4.2 // indirect | 	github.com/labstack/gommon v0.4.2 // indirect | ||||||
| 	github.com/mattn/go-colorable v0.1.14 // indirect | 	github.com/mattn/go-colorable v0.1.14 // indirect | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							| @@ -6,6 +6,8 @@ gitea.elara.ws/Hazel/words v1.0.5 h1:FjpQezXDPxgNing/DAMJStLT3TC7/dxvCQj3Cg3AJB4 | |||||||
| gitea.elara.ws/Hazel/words v1.0.5/go.mod h1:IwQ+eZpY2Kr02RPYpyFDjHNJPPbsf1NOvgc4ZMeg2zg= | gitea.elara.ws/Hazel/words v1.0.5/go.mod h1:IwQ+eZpY2Kr02RPYpyFDjHNJPPbsf1NOvgc4ZMeg2zg= | ||||||
| github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk= | github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk= | ||||||
| github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc= | github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc= | ||||||
|  | github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= | ||||||
|  | github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | ||||||
| github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA= | github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA= | ||||||
| github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= | github.com/labstack/echo/v4 v4.13.4/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= | ||||||
| github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= | github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= | ||||||
|   | |||||||
							
								
								
									
										24
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								main.go
									
									
									
									
									
								
							| @@ -1,42 +1,18 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"errors" |  | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" |  | ||||||
| 	"text/template" |  | ||||||
|  |  | ||||||
| 	"gitea.elara.ws/Hazel/hangman/internal/rest_handler" | 	"gitea.elara.ws/Hazel/hangman/internal/rest_handler" | ||||||
| 	"gitea.elara.ws/Hazel/hangman/internal/view_handler" | 	"gitea.elara.ws/Hazel/hangman/internal/view_handler" | ||||||
| 	"github.com/labstack/echo/v4" | 	"github.com/labstack/echo/v4" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type TemplateRegistry struct { |  | ||||||
| 	templates map[string]*template.Template |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Implement e.Renderer interface |  | ||||||
| func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c echo.Context) error { |  | ||||||
| 	tmpl, ok := t.templates[name] |  | ||||||
| 	if !ok { |  | ||||||
| 		err := errors.New("Template not found -> " + name) |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 	return tmpl.ExecuteTemplate(w, "base.html", data) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| 	fmt.Println("wanna play hangman? Well ya cant since it isn't implemented yet..") | 	fmt.Println("wanna play hangman? Well ya cant since it isn't implemented yet..") | ||||||
|  |  | ||||||
| 	e := echo.New() | 	e := echo.New() | ||||||
|  |  | ||||||
| 	templates := make(map[string]*template.Template) |  | ||||||
| 	templates["create_session"] = template.Must(template.ParseFiles("templates/create_session.html", "templates/base.html")) |  | ||||||
| 	templates["create_user"] = template.Must(template.ParseFiles("templates/create_user.html", "templates/base.html")) |  | ||||||
| 	e.Renderer = &TemplateRegistry{ |  | ||||||
| 		templates: templates, |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	e.POST("/api/session", rest_handler.CreateSession) | 	e.POST("/api/session", rest_handler.CreateSession) | ||||||
| 	e.POST("/api/:session/user", rest_handler.CreateUser) | 	e.POST("/api/:session/user", rest_handler.CreateUser) | ||||||
| 	e.POST("/api/:session/test-auth", rest_handler.TestAuth) | 	e.POST("/api/:session/test-auth", rest_handler.TestAuth) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user