implement proper sever route handling

This commit is contained in:
Robin Olsen
2026-02-02 14:16:08 +01:00
parent 622e830f6e
commit c69fd84fdd
10 changed files with 290 additions and 35 deletions

View File

@@ -1,16 +1,16 @@
package server
import (
"github.com/LazyBachelor/LazyPM/internal/service"
"embed"
"net/http"
"time"
"github.com/LazyBachelor/LazyPM/internal/service"
)
type Server struct {
Address string
Assets embed.FS
Routes []Route
Services *service.Services
}
@@ -20,9 +20,11 @@ func NewServer(props Server) *http.Server {
props.Address = "localhost:8080"
}
handler := props.RegisterRoutes(props.Assets)
return &http.Server{
Addr: props.Address,
Handler: props.RegisterRoutes(props.Assets, props.Routes),
Handler: handler,
IdleTimeout: time.Minute,
ReadTimeout: time.Second * 10,
WriteTimeout: time.Second * 10,