MCPcopy
hub / github.com/semaphoreui/semaphore / WriteJSON

Function WriteJSON

api/helpers/write_response.go:15–27  ·  view source on GitHub ↗

WriteJSON writes object as JSON

(w http.ResponseWriter, code int, out any)

Source from the content-addressed store, hash-verified

13
14// WriteJSON writes object as JSON
15func WriteJSON(w http.ResponseWriter, code int, out any) {
16 w.Header().Set("content-type", "application/json")
17 w.WriteHeader(code)
18
19 if out == nil {
20 return
21 }
22
23 if err := json.NewEncoder(w).Encode(out); err != nil {
24 log.Error(err)
25 debug.PrintStack()
26 }
27}
28
29func WriteErrorStatus(w http.ResponseWriter, err string, code int) {
30 WriteJSON(w, code, map[string]string{

Callers 15

GetRunnersMethod · 0.92
AddRunnerMethod · 0.92
RunnerMiddlewareMethod · 0.92
GetRunnerMethod · 0.92
GetRunnerTagsMethod · 0.92
clearCacheFunction · 0.92
GetUsersMethod · 0.92
AddUserMethod · 0.92
enableTotpFunction · 0.92
setOptionFunction · 0.92
getOptionsFunction · 0.92

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected