MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier
(next http.HandlerFunc, notifiers []HTTPNotifier)
| 17 | |
| 18 | // MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier |
| 19 | func MakeNotifierWrapper(next http.HandlerFunc, notifiers []HTTPNotifier) http.HandlerFunc { |
| 20 | return func(w http.ResponseWriter, r *http.Request) { |
| 21 | then := time.Now() |
| 22 | url := r.URL.String() |
| 23 | |
| 24 | writer := httputil.NewHttpWriteInterceptor(w) |
| 25 | next(writer, r) |
| 26 | |
| 27 | for _, notifier := range notifiers { |
| 28 | notifier.Notify(r.Method, url, url, writer.Status(), "completed", time.Since(then)) |
| 29 | } |
| 30 | } |
| 31 | } |
searching dependent graphs…