mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 18:12:50 +01:00
feat(api): add GET /version endpoint
Returns the server name and configured client mode as JSON, enabling clients like MHBridge to display server version info.
This commit is contained in:
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- API: `GET /version` endpoint returning server name and client mode (`{"clientMode":"ZZ","name":"Erupe-CE"}`)
|
||||||
- Rework object ID allocation: per-session IDs replace shared map, simplify stage entry notifications
|
- Rework object ID allocation: per-session IDs replace shared map, simplify stage entry notifications
|
||||||
- Better config file handling and structure
|
- Better config file handling and structure
|
||||||
- Comprehensive production logging for save operations (warehouse, Koryo points, savedata, Hunter Navi, plate equipment)
|
- Comprehensive production logging for save operations (warehouse, Koryo points, savedata, Hunter Navi, plate equipment)
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ func (s *APIServer) Start() error {
|
|||||||
r.HandleFunc("/character/export", s.ExportSave)
|
r.HandleFunc("/character/export", s.ExportSave)
|
||||||
r.HandleFunc("/api/ss/bbs/upload.php", s.ScreenShot)
|
r.HandleFunc("/api/ss/bbs/upload.php", s.ScreenShot)
|
||||||
r.HandleFunc("/api/ss/bbs/{id}", s.ScreenShotGet)
|
r.HandleFunc("/api/ss/bbs/{id}", s.ScreenShotGet)
|
||||||
|
r.HandleFunc("/version", s.Version)
|
||||||
handler := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}))(r)
|
handler := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}))(r)
|
||||||
s.httpServer.Handler = handlers.LoggingHandler(os.Stdout, handler)
|
s.httpServer.Handler = handlers.LoggingHandler(os.Stdout, handler)
|
||||||
s.httpServer.Addr = fmt.Sprintf(":%d", s.erupeConfig.API.Port)
|
s.httpServer.Addr = fmt.Sprintf(":%d", s.erupeConfig.API.Port)
|
||||||
|
|||||||
@@ -123,6 +123,22 @@ func (s *APIServer) newAuthData(userID uint32, userRights uint32, userTokenID ui
|
|||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionResponse is the JSON payload returned by the /version endpoint.
|
||||||
|
type VersionResponse struct {
|
||||||
|
ClientMode string `json:"clientMode"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version handles GET /version and returns the server name and client mode.
|
||||||
|
func (s *APIServer) Version(w http.ResponseWriter, r *http.Request) {
|
||||||
|
resp := VersionResponse{
|
||||||
|
ClientMode: s.erupeConfig.ClientMode,
|
||||||
|
Name: "Erupe-CE",
|
||||||
|
}
|
||||||
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
_ = json.NewEncoder(w).Encode(resp)
|
||||||
|
}
|
||||||
|
|
||||||
// Launcher handles GET /launcher and returns banners, messages, and links for the launcher UI.
|
// Launcher handles GET /launcher and returns banners, messages, and links for the launcher UI.
|
||||||
func (s *APIServer) Launcher(w http.ResponseWriter, r *http.Request) {
|
func (s *APIServer) Launcher(w http.ResponseWriter, r *http.Request) {
|
||||||
var respData LauncherResponse
|
var respData LauncherResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user