handleViewHome shows page at root path. It checks the configuration and authentication state to show the correct page.
(app *App, w http.ResponseWriter, r *http.Request)
| 224 | // handleViewHome shows page at root path. It checks the configuration and |
| 225 | // authentication state to show the correct page. |
| 226 | func handleViewHome(app *App, w http.ResponseWriter, r *http.Request) error { |
| 227 | if app.cfg.App.SingleUser { |
| 228 | // Render blog index |
| 229 | return handleViewCollection(app, w, r) |
| 230 | } |
| 231 | |
| 232 | // Multi-user instance |
| 233 | forceLanding := r.FormValue("landing") == "1" |
| 234 | if !forceLanding { |
| 235 | // Show correct page based on user auth status and configured landing path |
| 236 | u := getUserSession(app, r) |
| 237 | |
| 238 | if app.cfg.App.Chorus { |
| 239 | // This instance is focused on reading, so show Reader on home route if not |
| 240 | // private or a private-instance user is logged in. |
| 241 | if !app.cfg.App.Private || u != nil { |
| 242 | return viewLocalTimeline(app, w, r) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | if u != nil { |
| 247 | // User is logged in, so show the Pad |
| 248 | return handleViewPad(app, w, r) |
| 249 | } |
| 250 | |
| 251 | if app.cfg.App.Private { |
| 252 | return viewLogin(app, w, r) |
| 253 | } |
| 254 | |
| 255 | if land := app.cfg.App.LandingPath(); land != "/" { |
| 256 | return impart.HTTPError{http.StatusFound, land} |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return handleViewLanding(app, w, r) |
| 261 | } |
| 262 | |
| 263 | func handleViewLanding(app *App, w http.ResponseWriter, r *http.Request) error { |
| 264 | forceLanding := r.FormValue("landing") == "1" |
nothing calls this directly
no test coverage detected