MCPcopy
hub / github.com/openfaas/faas / MakeNotifierWrapper

Function MakeNotifierWrapper

gateway/handlers/notifier_handler.go:19–31  ·  view source on GitHub ↗

MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier

(next http.HandlerFunc, notifiers []HTTPNotifier)

Source from the content-addressed store, hash-verified

17
18// MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier
19func 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}

Calls 1

NotifyMethod · 0.65

Used in the wild real call sites across dependent graphs

searching dependent graphs…