passwd-mgr/main.go

30 lines
652 B
Go
Raw Normal View History

2024-06-20 13:47:04 +00:00
package main
import (
"net/http"
"erius.ru/passwd-mgr/components"
2024-06-20 13:47:04 +00:00
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
2024-06-20 13:47:04 +00:00
)
func Render(ctx echo.Context, statusCode int, t templ.Component) error {
buf := templ.GetBuffer()
defer templ.ReleaseBuffer(buf)
if err := t.Render(ctx.Request().Context(), buf); err != nil {
return err
}
return ctx.HTML(statusCode, buf.String())
}
2024-06-20 13:47:04 +00:00
func main() {
e := echo.New()
e.Static("/assets", "assets")
e.Use(middleware.Logger())
e.GET("/", func(c echo.Context) error {
return Render(c, http.StatusOK, components.Index())
})
e.Logger.Fatal(e.Start(":8080"))
2024-06-20 13:47:04 +00:00
}