2024-06-20 13:47:04 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2024-06-21 00:23:21 +00:00
|
|
|
"erius.ru/passwd-mgr/components"
|
2024-06-20 13:47:04 +00:00
|
|
|
"github.com/a-h/templ"
|
2024-06-21 00:23:21 +00:00
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
"github.com/labstack/echo/v4/middleware"
|
2024-06-20 13:47:04 +00:00
|
|
|
)
|
|
|
|
|
2024-06-21 00:23:21 +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() {
|
2024-06-21 00:23:21 +00:00
|
|
|
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
|
|
|
}
|