INNER CODE UNIT · Go

http

megaease/easemesh · go-sdk/stdlib/stdlib.go:119

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,
		// in the case of fn invoking w.WriteHeader.
	}
}

// WrapHandleFunc is the wrapper of WrapHandleFunc of default agent.
func WrapHandleFunc(fn http.HandlerFunc) http.HandlerFunc {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…