package web import ( "fmt" "github.com/gofiber/fiber/v2" "go.fifitido.net/ytdl-web/config" "golang.org/x/exp/slog" ) func Serve(cfg *config.Config) error { engine := ViewsEngine() app := fiber.New(fiber.Config{ Views: engine, EnableTrustedProxyCheck: true, TrustedProxies: cfg.HTTP.TrustedProxies, DisableStartupMessage: true, }) routes := &routes{} routes.Register(app) listenAddr := fmt.Sprintf("%s:%d", cfg.HTTP.Listen, cfg.HTTP.Port) slog.Info("Starting HTTP server", slog.String("host", cfg.HTTP.Listen), slog.Int("port", cfg.HTTP.Port)) return app.Listen(listenAddr) }