MCPcopy
hub / github.com/writefreely/writefreely / RedirectOnErr

Method RedirectOnErr

handle.go:362–377  ·  view source on GitHub ↗
(f handlerFunc, loc string)

Source from the content-addressed store, hash-verified

360}
361
362func (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
379func (h *Handler) Page(n string) http.HandlerFunc {
380 return h.Web(func(app *App, w http.ResponseWriter, r *http.Request) error {

Callers

nothing calls this directly

Calls 1

fFunction · 0.50

Tested by

no test coverage detected