(w http.ResponseWriter, r *http.Request)
| 194 | } |
| 195 | |
| 196 | func (h Port80Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 197 | path := r.RequestURI |
| 198 | if path == "/debug" || strings.HasPrefix(path, "/debug") { |
| 199 | h.Main.ServeHTTP(w, r) |
| 200 | return |
| 201 | } |
| 202 | if r.Method != "GET" && r.Method != "HEAD" { |
| 203 | http.Error(w, "Use HTTPS", http.StatusBadRequest) |
| 204 | return |
| 205 | } |
| 206 | if path == "/" && AllowDebugAccess(r) { |
| 207 | // Redirect authorized user to the debug handler. |
| 208 | path = "/debug/" |
| 209 | } |
| 210 | host := cmp.Or(h.FQDN, r.Host) |
| 211 | target := "https://" + host + path |
| 212 | http.Redirect(w, r, target, http.StatusFound) |
| 213 | } |
| 214 | |
| 215 | // ReturnHandler is like net/http.Handler, but the handler can return an |
| 216 | // error instead of writing to its ResponseWriter. |
nothing calls this directly
no test coverage detected