mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Add new middleware for adding headers
This commit is contained in:
@@ -31,3 +31,16 @@ func Merge(middlesware ...Interface) Interface {
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
// AddHeaders produces a middleware which merges the given header values into the response,
|
||||
// overwriting the existing value if any.
|
||||
func AddHeaders(headers map[string]string) Interface {
|
||||
return Func(func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
for key, value := range headers {
|
||||
w.Header().Set(key, value)
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user