package main import ( "fmt" "log/slog" "net/http" "os" "strings" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/r3labs/sse/v2" "gitlab.unjx.de/flohoss/godash/handlers" "gitlab.unjx.de/flohoss/godash/internal/env" "gitlab.unjx.de/flohoss/godash/services" ) func main() { env, err := env.Parse() if err != nil { slog.Error("cannot parse environment variables", "err", err) os.Exit(1) } e := echo.New() e.HideBanner = true e.HidePort = true e.Debug = true e.Pre(middleware.RemoveTrailingSlash()) e.Use(middleware.Recover()) e.Use(middleware.GzipWithConfig(middleware.GzipConfig{ Skipper: func(c echo.Context) bool { return strings.Contains(c.Path(), "sse") }, })) e.Static("/", "assets") e.Static("/storage/icons", "storage/icons") sse := sse.New() sse.AutoReplay = false s := services.NewSystemService(sse) w := services.NewWeatherService(sse, env) b := services.NewBookmarkService() ah := handlers.NewAppHandler(env, s, w, b) handlers.SetupRoutes(e, sse, ah) slog.Info("starting server", "url", fmt.Sprintf("http://localhost:%d", env.Port)) if err := e.Start(fmt.Sprintf(":%d", env.Port)); err != http.ErrServerClosed { slog.Error("cannot start server", "err", err) os.Exit(1) } }