Started server

This commit is contained in:
Simon Martens
2026-02-19 15:09:44 +01:00
parent df79656c77
commit 59fb813c85
7 changed files with 115 additions and 94 deletions

30
lenz.go
View File

@@ -1,13 +1,10 @@
package main
import (
"io/fs"
"log/slog"
"github.com/Theodor-Springmann-Stiftung/lenz-web/app"
_ "github.com/Theodor-Springmann-Stiftung/lenz-web/pages"
"github.com/Theodor-Springmann-Stiftung/lenz-web/templates"
"github.com/labstack/echo/v5"
"github.com/Theodor-Springmann-Stiftung/lenz-web/server"
)
func main() {
@@ -25,28 +22,19 @@ func main() {
panic(err)
}
e := echo.New()
publicFS, err := fs.Sub(templates.PublicFS, "public")
err = Serve(application)
if err != nil {
panic(err)
}
e.StaticFS("/public", publicFS)
}
for _, route := range application.Routes() {
routePath := route.Path
e.GET(routePath, func(c *echo.Context) error {
out, err := application.RenderPath(routePath)
if err != nil {
return err
}
return c.HTMLBlob(200, out)
})
}
addr := cfg.Address + ":" + cfg.Port
if err := e.Start(addr); err != nil {
panic(err)
func Serve(app *app.App) error {
server, err := server.NewServer(app)
if err != nil {
return err
}
server.Start()
return nil
}
func GetConfig() (app.Config, error) {