mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2026-03-21 05:45:32 +00:00
Started server
This commit is contained in:
30
lenz.go
30
lenz.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user