MCPcopy
hub / github.com/filebrowser/filebrowser / renderJSON

Function renderJSON

http/utils.go:15–28  ·  view source on GitHub ↗
(w http.ResponseWriter, _ *http.Request, data interface{})

Source from the content-addressed store, hash-verified

13)
14
15func renderJSON(w http.ResponseWriter, _ *http.Request, data interface{}) (int, error) {
16 marsh, err := json.Marshal(data)
17
18 if err != nil {
19 return http.StatusInternalServerError, err
20 }
21
22 w.Header().Set("Content-Type", "application/json; charset=utf-8")
23 if _, err := w.Write(marsh); err != nil {
24 return http.StatusInternalServerError, err
25 }
26
27 return 0, nil
28}
29
30func errToStatus(err error) int {
31 switch {

Callers 5

share.goFile · 0.85
users.goFile · 0.85
public.goFile · 0.85
settings.goFile · 0.85
resource.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected