diff --git a/app/transports/api/api.go b/app/transports/api/api.go index 997a3f921..36a729094 100644 --- a/app/transports/api/api.go +++ b/app/transports/api/api.go @@ -13,6 +13,7 @@ import ( "github.com/openmultiplayer/web/app/services/authentication" "github.com/openmultiplayer/web/app/transports/api/auth" "github.com/openmultiplayer/web/app/transports/api/docs" + "github.com/openmultiplayer/web/app/transports/api/launcher" "github.com/openmultiplayer/web/app/transports/api/legacy" "github.com/openmultiplayer/web/app/transports/api/metrics" "github.com/openmultiplayer/web/app/transports/api/pawndex" @@ -32,6 +33,7 @@ func Build() fx.Option { servers.Build(), users.Build(), pawndex.Build(), + launcher.Build(), // Starts the HTTP server in a goroutine and fatals if it errors. fx.Invoke(func(l *zap.Logger, server *http.Server) { @@ -72,10 +74,6 @@ func Build() fx.Option { web.Write(w, map[string]string{"version": version.Version}) //nolint:errcheck }) - router.Get("/launcher", func(w http.ResponseWriter, r *http.Request) { - web.Write(w, map[string]string{"version": cfg.LauncherVersion, "download": "https://github.com/openmultiplayer/launcher/releases"}) //nolint:errcheck - }) - router.HandleFunc( "/{rest:[a-zA-Z0-9=\\-\\/]+}", func(w http.ResponseWriter, r *http.Request) { diff --git a/app/transports/api/launcher/api.go b/app/transports/api/launcher/api.go new file mode 100644 index 000000000..9a337ebc9 --- /dev/null +++ b/app/transports/api/launcher/api.go @@ -0,0 +1,31 @@ +package launcher + +import ( + "net/http" + + "github.com/go-chi/chi" + "github.com/openmultiplayer/web/internal/config" + "github.com/openmultiplayer/web/internal/web" + "go.uber.org/fx" +) + +func Build() fx.Option { + return fx.Options( + fx.Invoke(func( + r chi.Router, + cfg config.Config, + ) { + + launcherInfo := map[string]string{ + "version": cfg.LauncherVersion, + "download": "https://github.com/openmultiplayer/launcher/releases", + "changelog": `|- Build 1 - 2023/10/08 +Release beta version`, + } + + r.Get("/launcher", func(w http.ResponseWriter, r *http.Request) { + web.Write(w, launcherInfo) //nolint:errcheck + }) + }), + ) +}