(rw http.ResponseWriter, req *http.Request)
| 176 | } |
| 177 | |
| 178 | func (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 | |
| 212 | func (h *Handler) handleVerify(rw http.ResponseWriter, req *http.Request) { |
| 213 | req.ParseForm() |
nothing calls this directly
no test coverage detected