| 360 | } |
| 361 | |
| 362 | func (h *Handler) RedirectOnErr(f handlerFunc, loc string) handlerFunc { |
| 363 | return func(app *App, w http.ResponseWriter, r *http.Request) error { |
| 364 | err := f(app, w, r) |
| 365 | if err != nil { |
| 366 | if ie, ok := err.(impart.HTTPError); ok { |
| 367 | // Override default redirect with returned error's, if it's a |
| 368 | // redirect error. |
| 369 | if ie.Status == http.StatusFound { |
| 370 | return ie |
| 371 | } |
| 372 | } |
| 373 | return impart.HTTPError{http.StatusFound, loc} |
| 374 | } |
| 375 | return nil |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | func (h *Handler) Page(n string) http.HandlerFunc { |
| 380 | return h.Web(func(app *App, w http.ResponseWriter, r *http.Request) error { |