MCPcopy
hub / github.com/perkeep/perkeep / ServeHTTP

Method ServeHTTP

pkg/server/help.go:139–162  ·  view source on GitHub ↗
(rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

137}
138
139func (hh *HelpHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
140 suffix := httputil.PathSuffix(req)
141 if !httputil.IsGet(req) {
142 http.Error(rw, "Illegal help method.", http.StatusMethodNotAllowed)
143 return
144 }
145 switch suffix {
146 case "":
147 cc, err := fixServerInConfig(hh.clientConfig, req)
148 if err != nil {
149 httputil.ServeError(rw, req, err)
150 return
151 }
152 if clientConfig := req.FormValue("clientConfig"); clientConfig != "" {
153 if clientConfigOnly, err := strconv.ParseBool(clientConfig); err == nil && clientConfigOnly {
154 httputil.ReturnJSON(rw, cc)
155 return
156 }
157 }
158 hh.serveHelpHTML(cc, rw, req)
159 default:
160 http.Error(rw, "Illegal help path.", http.StatusNotFound)
161 }
162}
163
164func (hh *HelpHandler) serveHelpHTML(cc *clientconfig.Config, rw http.ResponseWriter, req *http.Request) {
165 jsonBytes, err := json.MarshalIndent(cc, "", " ")

Callers

nothing calls this directly

Calls 7

serveHelpHTMLMethod · 0.95
PathSuffixFunction · 0.92
IsGetFunction · 0.92
ServeErrorFunction · 0.92
ReturnJSONFunction · 0.92
fixServerInConfigFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected