(f gopherFunc)
| 982 | } |
| 983 | |
| 984 | func (h *Handler) Gopher(f gopherFunc) gopher.HandlerFunc { |
| 985 | return func(w gopher.ResponseWriter, r *gopher.Request) { |
| 986 | defer func() { |
| 987 | if e := recover(); e != nil { |
| 988 | log.Error("%s: %s", e, debug.Stack()) |
| 989 | w.WriteError("An internal error occurred") |
| 990 | } |
| 991 | log.Info("gopher: %s", r.Selector) |
| 992 | }() |
| 993 | |
| 994 | err := f(h.app.App(), w, r) |
| 995 | if err != nil { |
| 996 | log.Error("failed: %s", err) |
| 997 | w.WriteError("the page failed for some reason (see logs)") |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | func sendRedirect(w http.ResponseWriter, code int, location string) int { |
| 1003 | w.Header().Set("Location", location) |
no test coverage detected