diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ab203d00..2b5607b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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 - Better config file handling and structure - Comprehensive production logging for save operations (warehouse, Koryo points, savedata, Hunter Navi, plate equipment) diff --git a/server/api/api_server.go b/server/api/api_server.go index 75f31e342..c689a6618 100644 --- a/server/api/api_server.go +++ b/server/api/api_server.go @@ -55,6 +55,7 @@ func (s *APIServer) Start() error { r.HandleFunc("/character/export", s.ExportSave) r.HandleFunc("/api/ss/bbs/upload.php", s.ScreenShot) r.HandleFunc("/api/ss/bbs/{id}", s.ScreenShotGet) + r.HandleFunc("/version", s.Version) handler := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"}))(r) s.httpServer.Handler = handlers.LoggingHandler(os.Stdout, handler) s.httpServer.Addr = fmt.Sprintf(":%d", s.erupeConfig.API.Port) diff --git a/server/api/endpoints.go b/server/api/endpoints.go index b5b612a68..2a41f9b7d 100644 --- a/server/api/endpoints.go +++ b/server/api/endpoints.go @@ -123,6 +123,22 @@ func (s *APIServer) newAuthData(userID uint32, userRights uint32, userTokenID ui 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. func (s *APIServer) Launcher(w http.ResponseWriter, r *http.Request) { var respData LauncherResponse