(w http.ResponseWriter, r *http.Request)
| 173 | } |
| 174 | |
| 175 | func (rh *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 176 | if wantsDiscovery(r) { |
| 177 | if auth.Allowed(r, auth.OpDiscovery) { |
| 178 | rh.serveDiscovery(w, r) |
| 179 | return |
| 180 | } |
| 181 | if !rh.Stealth { |
| 182 | auth.SendUnauthorized(w, r) |
| 183 | } |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | if rh.Stealth { |
| 188 | return |
| 189 | } |
| 190 | if r.RequestURI == "/" && rh.ui != nil { |
| 191 | http.Redirect(w, r, "/ui/", http.StatusMovedPermanently) |
| 192 | return |
| 193 | } |
| 194 | switch r.URL.Path { |
| 195 | case "/favicon.ico": |
| 196 | ServeStaticFile(w, r, &Files, "favicon.ico") |
| 197 | return |
| 198 | case "/mobile-setup": |
| 199 | http.Redirect(w, r, "/ui/mobile.html", http.StatusFound) |
| 200 | return |
| 201 | case "/": |
| 202 | break |
| 203 | default: |
| 204 | http.NotFound(w, r) |
| 205 | return |
| 206 | } |
| 207 | |
| 208 | f := func(p string, a ...interface{}) { |
| 209 | fmt.Fprintf(w, p, a...) |
| 210 | } |
| 211 | f("<html><body><p>This is perkeepd (%s), a "+ |
| 212 | "<a href='http://perkeep.org'>Perkeep</a> server.</p>", |
| 213 | html.EscapeString(buildinfo.Summary())) |
| 214 | if rh.ui != nil { |
| 215 | f("<p>To manage your content, access the <a href='%s'>%s</a>.</p>", rh.ui.prefix, rh.ui.prefix) |
| 216 | } |
| 217 | if rh.statusRoot != "" { |
| 218 | f("<p>To view status, see <a href='%s'>%s</a>.</p>", rh.statusRoot, rh.statusRoot) |
| 219 | } |
| 220 | if rh.helpRoot != "" { |
| 221 | f("<p>To view more information on accessing the server, see <a href='%s'>%s</a>.</p>", rh.helpRoot, rh.helpRoot) |
| 222 | } |
| 223 | fmt.Fprintf(w, "</body></html>") |
| 224 | } |
| 225 | |
| 226 | type byFromTo []*SyncHandler |
| 227 |
nothing calls this directly
no test coverage detected