From 74ea6270c8fea48733a5fc344e2d36f718037083 Mon Sep 17 00:00:00 2001 From: Hazel Noack Date: Tue, 1 Jul 2025 12:20:58 +0200 Subject: [PATCH] removed templates from main --- go.mod | 1 + go.sum | 2 ++ main.go | 24 ------------------------ 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 9704f65..f1edd61 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a // indirect gitea.elara.ws/Hazel/words v1.0.5 // 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/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.14 // indirect diff --git a/go.sum b/go.sum index f61fdfb..f281f03 100644 --- a/go.sum +++ b/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= 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/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/go.mod h1:g63b33BZ5vZzcIUF8AtRH40DrTlXnx4UMC8rBdndmjQ= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= diff --git a/main.go b/main.go index d4b18a8..d58489b 100644 --- a/main.go +++ b/main.go @@ -1,42 +1,18 @@ package main import ( - "errors" "fmt" - "io" - "text/template" "gitea.elara.ws/Hazel/hangman/internal/rest_handler" "gitea.elara.ws/Hazel/hangman/internal/view_handler" "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() { fmt.Println("wanna play hangman? Well ya cant since it isn't implemented yet..") 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/user", rest_handler.CreateUser) e.POST("/api/:session/test-auth", rest_handler.TestAuth)