aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 16:50:43 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 16:50:43 -0400
commit7b41d76ba9e3e66ebc9d6bb0a88a9c5b01d496bd (patch)
treef49cd77d1ffa640825e71725642c9dac795d11dc /pkg/api
parent607c5190328cf15cd237cfda19a1f4561905efd6 (diff)
downloadAtlas-7b41d76ba9e3e66ebc9d6bb0a88a9c5b01d496bd.tar.gz
Atlas-7b41d76ba9e3e66ebc9d6bb0a88a9c5b01d496bd.zip
pkg/api/api0: Implement /client/mainmenupromos
Also support varying it so things like version-specific messages can be shown.
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/api0/api.go5
-rw-r--r--pkg/api/api0/client.go66
-rw-r--r--pkg/api/api0/clientserver.go32
-rw-r--r--pkg/api/api0/server.go12
4 files changed, 83 insertions, 32 deletions
diff --git a/pkg/api/api0/api.go b/pkg/api/api0/api.go
index 33207a1..7d1e638 100644
--- a/pkg/api/api0/api.go
+++ b/pkg/api/api0/api.go
@@ -28,6 +28,9 @@ type Handler struct {
// PdataStorage stores player data. It must be non-nil.
PdataStorage PdataStorage
+ // MainMenuPromos gets the main menu promos to return for a request.
+ MainMenuPromos func(*http.Request) MainMenuPromos
+
// NotFound handles requests not handled by this Handler.
NotFound http.Handler
}
@@ -37,6 +40,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "Atlas")
switch r.URL.Path {
+ case "/client/mainmenupromos":
+ h.handleMainMenuPromos(w, r)
case "/accounts/write_persistence":
h.handleAccountsWritePersistence(w, r)
case "/accounts/get_username":
diff --git a/pkg/api/api0/client.go b/pkg/api/api0/client.go
new file mode 100644
index 0000000..7874872
--- /dev/null
+++ b/pkg/api/api0/client.go
@@ -0,0 +1,66 @@
+package api0
+
+import (
+ "net/http"
+)
+
+type MainMenuPromos struct {
+ NewInfo MainMenuPromosNew `json:"newInfo"`
+ LargeButton MainMenuPromosButtonLarge `json:"largeButton"`
+ SmallButton1 MainMenuPromosButtonSmall `json:"smallButton1"`
+ SmallButton2 MainMenuPromosButtonSmall `json:"smallButton2"`
+}
+
+type MainMenuPromosNew struct {
+ Title1 string `json:"Title1"`
+ Title2 string `json:"Title2"`
+ Title3 string `json:"Title3"`
+}
+
+type MainMenuPromosButtonLarge struct {
+ Title string `json:"Title"`
+ Text string `json:"Text"`
+ Url string `json:"Url"`
+ ImageIndex int `json:"ImageIndex"`
+}
+
+type MainMenuPromosButtonSmall struct {
+ Title string `json:"Title"`
+ Url string `json:"Url"`
+ ImageIndex int `json:"ImageIndex"`
+}
+
+func (h *Handler) handleMainMenuPromos(w http.ResponseWriter, r *http.Request) {
+ if r.Method != http.MethodOptions && r.Method != http.MethodHead && r.Method != http.MethodGet {
+ http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
+ return
+ }
+
+ w.Header().Set("Cache-Control", "private, no-cache, no-store")
+ w.Header().Set("Expires", "0")
+ w.Header().Set("Pragma", "no-cache")
+
+ if r.Method == http.MethodOptions {
+ w.Header().Set("Allow", "OPTIONS, HEAD, GET")
+ w.WriteHeader(http.StatusNoContent)
+ return
+ }
+
+ var p MainMenuPromos
+ if h.MainMenuPromos != nil {
+ p = h.MainMenuPromos(r)
+ }
+ respJSON(w, r, http.StatusOK, p)
+}
+
+/*
+ /client/origin_auth:
+ GET:
+ /client/auth_with_server:
+ POST:
+ /client/auth_with_self:
+ POST:
+
+ /client/servers:
+ GET:
+*/
diff --git a/pkg/api/api0/clientserver.go b/pkg/api/api0/clientserver.go
deleted file mode 100644
index 858e8aa..0000000
--- a/pkg/api/api0/clientserver.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package api0
-
-/*
- /accounts/write_persistence:
- POST:
-
- /accounts/lookup_uid:
- GET:
- /accounts/get_username:
- GET:
-
- /client/mainmenupromos:
- GET:
-
- /client/origin_auth:
- GET:
- /client/auth_with_server:
- POST:
- /client/auth_with_self:
- POST:
-
- /client/servers:
- POST:
- /server/add_server:
- POST:
- /server/heartbeat:
- POST:
- /server/update_values:
- POST:
- /server/remove_server:
- DELETE:
-*/
diff --git a/pkg/api/api0/server.go b/pkg/api/api0/server.go
new file mode 100644
index 0000000..d1a94bb
--- /dev/null
+++ b/pkg/api/api0/server.go
@@ -0,0 +1,12 @@
+package api0
+
+/*
+ /server/add_server:
+ POST:
+ /server/heartbeat:
+ POST:
+ /server/update_values:
+ POST:
+ /server/remove_server:
+ DELETE:
+*/