MCPcopy
hub / github.com/fabiolb/fabio / ServeHTTP

Method ServeHTTP

admin/api/paths.go:15–39  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

13}
14
15func (h *ManualPathsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
16 // we need this for testing.
17 // under normal circumstances this is never nil
18 if registry.Default == nil {
19 return
20 }
21
22 switch r.Method {
23 case "GET":
24 paths, err := registry.Default.ManualPaths()
25 if err != nil {
26 log.Print("[ERROR] ", err)
27 http.Error(w, err.Error(), http.StatusInternalServerError)
28 return
29 }
30 for i, p := range paths {
31 paths[i] = strings.TrimPrefix(p, h.Prefix)
32 }
33 writeJSON(w, r, paths)
34 return
35
36 default:
37 http.Error(w, "not allowed", http.StatusMethodNotAllowed)
38 }
39}

Callers

nothing calls this directly

Calls 3

writeJSONFunction · 0.85
ErrorMethod · 0.80
ManualPathsMethod · 0.65

Tested by

no test coverage detected