erius
d796a3c4e8
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
29 lines
652 B
Go
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"))
|
|
}
|