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

11
server/endpoints.go Normal file
View File

@@ -0,0 +1,11 @@
package server
import (
"github.com/Theodor-Springmann-Stiftung/lenz-web/templates"
"github.com/labstack/echo/v5"
)
func MapStatic(e *echo.Echo) {
// INFO: Static files here:
e.StaticFS("/public", templates.PublicFS)
}

36
server/server.go Normal file
View File

@@ -0,0 +1,36 @@
package server
import (
"html/template"
"github.com/Theodor-Springmann-Stiftung/lenz-web/app"
"github.com/labstack/echo/v5"
)
// WARNING: this is not thread-safe. You can not write and read from the server at the same time!
type Server struct {
server *echo.Echo
cfg app.Config
tmpl *template.Template
}
func NewServer(app *app.App) (*Server, error) {
s := &Server{
server: echo.New(),
cfg: app.Config(),
tmpl: app.Templates(),
}
// INFO: Endpoint mapping here:
MapStatic(s.server)
return s, nil
}
func (s *Server) Start() error {
addr := s.cfg.Address + ":" + s.cfg.Port
if err := s.server.Start(addr); err != nil {
return err
}
return nil
}