package gateway import ( "net/http" "git.yeij.top/AskaEth/Cyrene_v2/internal/contract/enums" ) // This file owns the read-only client metadata surface: GET /api/v1/meta/enums, // which publishes the authoritative platform/mood/mode tables (Android // collaboration B4, design/07 §6). Clients (Web, Android, an IM bridge) read the // tables instead of hardcoding their own id → label mapping, so a source badge or // a mood label cannot drift per client. The tables themselves live in // internal/contract/enums; this handler only serves them, so there is one source // of truth rather than a copy per consumer. // metaEnums is the GET /api/v1/meta/enums payload. `unknown` carries the // machine-readable fallback policy (enums.UnknownFallback) so a client reads the // tables and the rule for an unlisted value from the same response. type metaEnums struct { Platforms []enums.Item `json:"platforms"` Moods []enums.Item `json:"moods"` Modes []enums.Item `json:"modes"` Unknown string `json:"unknown"` } // handleListEnums serves the shared client enum tables. It is a pure projection // of the Go-side authority (no store, no error path) and contains nothing // sensitive, so it is gated like GET /api/v1/sessions: any authenticated role may // read it. // // Adding a value to a table is a non-breaking change for existing clients, which // must display an unlisted value raw (see enums.UnknownFallback) rather than // dropping it or erroring. func (s *Server) handleListEnums(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, metaEnums{ Platforms: enums.Platforms(), Moods: enums.Moods(), Modes: enums.Modes(), Unknown: enums.UnknownFallback, }) }