Skip to content

Commit

Permalink
proper launcher api with more information
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Oct 7, 2023
1 parent 434d645 commit 56b90e8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/transports/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
31 changes: 31 additions & 0 deletions app/transports/api/launcher/api.go
Original file line number Diff line number Diff line change
@@ -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
})
}),
)
}

0 comments on commit 56b90e8

Please sign in to comment.