passwd-mgr/main.go
erius d796a3c4e8 Added echo as backend web server
Added an example templ index.templ template
Create tailwind config for building css
Added Makefile to easily deplot and live-reload the app while developing
Added README.md
Added some other web assets in assets directory
2024-06-21 03:23:21 +03:00

29 lines
652 B
Go

package main
import (
"net/http"
"erius.ru/passwd-mgr/components"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
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())
}
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"))
}