middleware/logger.go
func RequestLogger(f LogFormatter) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			entry := f.NewLogEntry(r)
			ww := NewWrapResponseWriter(w, r.ProtoMajor)

			t1 := time.Now()
			defer func() {
				entry.Write(ww.Status(), ww.BytesWritten(), time.Since(t1))
			}()

			next.ServeHTTP(ww, WithLogEntry(r, entry))
		}
		return http.HandlerFunc(fn)
	}
}
func RequestLogger(f LogFormatter) func(next http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		fn := func(w http.ResponseWriter, r *http.Request) {
			entry := f.NewLogEntry(r)
			ww := NewWrapResponseWriter(w, r.ProtoMajor)

			t1 := time.Now()
			defer func() {
				entry.Write(ww.Status(), ww.BytesWritten(), time.Since(t1))
			}()

			next.ServeHTTP(ww, WithLogEntry(r, entry))
		}
		return http.HandlerFunc(fn)
	}
}
func RequestLogger ( f LogFormatter ) func ( next http . Handler ) http . Handler { return func ( next http . Handler ) http . Handler { fn := func ( w http . ResponseWriter , r * http . Request ) { entry := f . NewLogEntry ( r ) ww := NewWrapResponseWriter ( w , r . ProtoMajor ) t1 := time . Now ( ) defer func ( ) { entry . Write ( ww . Status ( ) , ww . BytesWritten ( ) , time . Since ( t1 ) ) } ( ) next . ServeHTTP ( ww , WithLogEntry ( r , entry ) ) } return http . HandlerFunc ( fn ) } }
// RequestLogger returns a logger handler using a custom LogFormatter.
RequestLogger returns a logger handler using a custom LogFormatter .