func Middleware(h func(http.Handler) http.Handler) middleware.Handler { return middleware.HandlerFunc(func(c context.Context, w http.ResponseWriter, r *http.Request) context.Context { h(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gogo.Next(c, w, r) })).ServeHTTP(w, r) return nil }) }
func (l *Logger) ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request) context.Context { start := time.Now() l.Printf("Started %s %s", r.Method, r.URL.Path) gogo.Next(c, w, r) res := w.(gogo.ResponseWriter) l.Printf("Completed %v %s in %v", res.Status(), http.StatusText(res.Status()), time.Since(start)) return nil }
func (rec *Recovery) ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request) context.Context { defer func() { if err := recover(); err != nil { w.WriteHeader(http.StatusInternalServerError) stack := make([]byte, rec.StackSize) stack = stack[:runtime.Stack(stack, rec.StackAll)] f := "PANIC: %s\n%s" rec.Logger.Printf(f, err, stack) if rec.PrintStack { fmt.Fprintf(w, f, err, stack) } else { fmt.Fprintf(w, "Internal Server Error") } } }() gogo.Next(c, w, r) return nil }
func (l *GorillaLogger) ServeHTTP(c context.Context, w http.ResponseWriter, r *http.Request) context.Context { gorillaHandlers.LoggingHandler(os.Stdout, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gogo.Next(c, w, r) })).ServeHTTP(w, r) return nil }