MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / writeJSON

Function writeJSON

internal/web/api.go:21–27  ·  view source on GitHub ↗
(w http.ResponseWriter, status int, v any)

Source from the content-addressed store, hash-verified

19}
20
21func writeJSON(w http.ResponseWriter, status int, v any) {
22 w.Header().Set("Content-Type", "application/json")
23 w.WriteHeader(status)
24 if err := json.NewEncoder(w).Encode(v); err != nil {
25 mudlog.Error("API", "action", "writeJSON", "error", err)
26 }
27}
28
29func writeAPIError(w http.ResponseWriter, status int, message string) {
30 writeJSON(w, status, APIResponse[struct{}]{

Callers 15

apiV1GetGameTimeFunction · 0.85
apiV1GetGameTimeCalendarFunction · 0.85
apiV1GetAudioFunction · 0.85
apiV1CreateAudioFunction · 0.85
apiV1PatchAudioFunction · 0.85
apiV1DeleteAudioFunction · 0.85
apiV2GetSpellsFunction · 0.85
apiV2GetSpellFunction · 0.85
apiV2CreateSpellFunction · 0.85

Calls 2

ErrorFunction · 0.92
SetMethod · 0.65

Tested by

no test coverage detected