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

Method ServeHTTP

pkg/jsonsign/signhandler/sig.go:178–210  ·  view source on GitHub ↗
(rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

176}
177
178func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
179 base := httputil.PathBase(req)
180 subPath := httputil.PathSuffix(req)
181 switch req.Method {
182 case "GET", "HEAD":
183 switch subPath {
184 case "":
185 http.Redirect(rw, req, base+"camli/sig/discovery", http.StatusFound)
186 return
187 case h.pubKeyBlobRefServeSuffix:
188 h.pubKeyHandler.ServeHTTP(rw, req)
189 return
190 case "camli/sig/sign":
191 fallthrough
192 case "camli/sig/verify":
193 http.Error(rw, "POST required", http.StatusBadRequest)
194 return
195 case "camli/sig/discovery":
196 httputil.ReturnJSON(rw, h.Discovery(base))
197 return
198 }
199 case "POST":
200 switch subPath {
201 case "camli/sig/sign":
202 h.handleSign(rw, req)
203 return
204 case "camli/sig/verify":
205 h.handleVerify(rw, req)
206 return
207 }
208 }
209 http.Error(rw, "Unsupported path or method.", http.StatusBadRequest)
210}
211
212func (h *Handler) handleVerify(rw http.ResponseWriter, req *http.Request) {
213 req.ParseForm()

Callers

nothing calls this directly

Calls 7

DiscoveryMethod · 0.95
handleSignMethod · 0.95
handleVerifyMethod · 0.95
PathBaseFunction · 0.92
PathSuffixFunction · 0.92
ReturnJSONFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected