git » gofer » commit b43a9d8

http: Improve SetHeader logging

author Alberto Bertogli
2020-06-08 01:14:07 UTC
committer Alberto Bertogli
2020-06-08 01:14:07 UTC
parent 1e1c31a3a73ae15db247d55fd2e0e7aae4e818b3

http: Improve SetHeader logging

Now that we fixed the logging chains, we can simplify the SetHeader
logging.

server/http.go +2 -6

diff --git a/server/http.go b/server/http.go
index 6286f51..d640cd0 100644
--- a/server/http.go
+++ b/server/http.go
@@ -420,16 +420,12 @@ func (w *statusWriter) Write(b []byte) (int, error) {
 
 func SetHeader(parent http.Handler, hdrs map[string]string) http.Handler {
 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		for k, v := range hdrs {
-			w.Header().Set(k, v)
-		}
-		parent.ServeHTTP(w, r)
-
-		// TODO: better chained contexts.
 		tr, _ := trace.FromContext(r.Context())
 		for k, v := range hdrs {
+			w.Header().Set(k, v)
 			tr.Printf("added header: %s: %q", k, v)
 		}
+		parent.ServeHTTP(w, r)
 	})
 }