INNER CODE UNIT · Go
Headers
megaease/easemesh · go-sdk/stdlib/stdlib.go:113
func Headers() []string {
return DefaultAgent.Headers()
}
// WrapHandleFunc wraps http.HandleFunc to serve agent role.
// It copies canary headers to reponse writer, the function itself must not alter them.
func (a *Agent) WrapHandleFunc(fn http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
keys := a.headers.Load().([]string)
for k, v := range r.Header.Clone() {
if strInSlice(k, keys) {
w.Header()[k] = v
}
}
fn(w, r)
// NOTE: Copying headers after fn it might not take effect,