feat: replace local web UI with REST API gateway for freesr and persistent integration (GaC-Srtool)
This commit is contained in:
1 parent
5b33715c1b
commit
9aab62414f
2 files changed
+514
-9
No files matched your search
@@ -32,15 +32,12 @@ type appState struct {
|
||||
}
|
||||
|
||||
func loadHotfix() map[string]VersionConfig {
|
||||
const path = "versions.json"
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return map[string]VersionConfig{}
|
||||
}
|
||||
out := map[string]VersionConfig{}
|
||||
if err := json.Unmarshal(raw, &out); err != nil {
|
||||
Log("malformed versions.json: " + err.Error())
|
||||
return map[string]VersionConfig{}
|
||||
if raw, err := os.ReadFile("hotfix.json"); err == nil {
|
||||
_ = json.Unmarshal(raw, &out)
|
||||
}
|
||||
if raw, err := os.ReadFile("versions.json"); err == nil {
|
||||
_ = json.Unmarshal(raw, &out)
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -54,6 +51,12 @@ func (a *appState) getOrInsertHotfix(version, dispatchSeed string) VersionConfig
|
||||
if cfg, ok := a.hotfixMap[version]; ok {
|
||||
return cfg
|
||||
}
|
||||
if cfg, ok := a.hotfixMap["CNBETAWin"+version]; ok {
|
||||
return cfg
|
||||
}
|
||||
if cfg, ok := a.hotfixMap["OSBETAWin"+version]; ok {
|
||||
return cfg
|
||||
}
|
||||
|
||||
Log(fmt.Sprintf("trying to fetch hotfix for version %s with dispatch seed %s", version, dispatchSeed))
|
||||
|
||||
@@ -354,10 +357,18 @@ func Listen() error {
|
||||
mux.HandleFunc("/account/ma-cn-passport/app/loginByPassword", func(w http.ResponseWriter, r *http.Request) { apnLoginReply(w) })
|
||||
mux.HandleFunc("/account/ma-cn-session/app/verify", func(w http.ResponseWriter, r *http.Request) { apnVerifyReply(w) })
|
||||
mux.HandleFunc("/srtools", srToolsSave)
|
||||
mux.HandleFunc("/", notFound)
|
||||
registerAPIRoutes(mux)
|
||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/" || r.URL.Path == "/dashboard" {
|
||||
apiRoot(w, r)
|
||||
return
|
||||
}
|
||||
notFound(w, r)
|
||||
})
|
||||
|
||||
addr := fmt.Sprintf("0.0.0.0:%d", Port)
|
||||
Log("sdkserver is listening at " + addr)
|
||||
Log(fmt.Sprintf("REST API Gateway is live at http://localhost:%d/ (for GaC-Srtool)", Port))
|
||||
return http.ListenAndServe(addr, mux)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user