diff --git a/cmd/main.go b/cmd/main.go index fc7b0f4..e42fec1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,17 +1,15 @@ package main import ( - "fmt" - "gitea.sitodosi.com/betology/got/handler" - "github.com/labstack/echo" + "github.com/labstack/echo/v4" ) func main() { app := echo.New() userHandler := handler.UserHandler{} - app.GET("/user", userHandler.HandlerUserShow()) + app.GET("/user", userHandler.HandlerUserShow) - app.Start(:3000) + app.Start(":3000") } diff --git a/go.mod b/go.mod index 63c76e5..33a78b4 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,8 @@ module gitea.sitodosi.com/betology/got go 1.21.6 require ( + github.com/a-h/templ v0.2.598 // indirect + github.com/labstack/echo v3.3.10+incompatible // indirect github.com/labstack/echo/v4 v4.11.4 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/go.sum b/go.sum index 453ca6f..03344d8 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +github.com/a-h/templ v0.2.598 h1:6jMIHv6wQZvdPxTuv87erW4RqN/FPU0wk7ZHN5wVuuo= +github.com/a-h/templ v0.2.598/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= +github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8= github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= diff --git a/handler/user.go b/handler/user.go index 795d407..7b52a68 100644 --- a/handler/user.go +++ b/handler/user.go @@ -8,5 +8,5 @@ import ( type UserHandler struct{} func (h UserHandler) HandlerUserShow(c echo.Context) error { - return user.Show().Render(c.Request().Context(), c.Response()) + return render(c, user.Show()) } diff --git a/handler/util.go b/handler/util.go new file mode 100644 index 0000000..bb0200a --- /dev/null +++ b/handler/util.go @@ -0,0 +1,10 @@ +package handler + +import ( + "github.com/a-h/templ" + "github.com/labstack/echo/v4" +) + +func render(c echo.Context, component templ.Component) error { + return component.Render(c.Request().Context(), c.Response()) +} diff --git a/view/user/show_templ.go b/view/user/show_templ.go new file mode 100644 index 0000000..b8518f6 --- /dev/null +++ b/view/user/show_templ.go @@ -0,0 +1,35 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.598 +package user + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +func Show() templ.Component { + return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) + if !templ_7745c5c3_IsBuffer { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("