From b174c0eb98162b8b592b2f53daab9e8436a71456 Mon Sep 17 00:00:00 2001 From: Peter Bourgon Date: Wed, 19 Apr 2017 09:40:42 +0200 Subject: [PATCH] transport/http: PopulateRequestContext Accept Add the request Accept header to the context, under the ContextKeyRequestAccept key. Closes #515. --- transport/http/request_response_funcs.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/http/request_response_funcs.go b/transport/http/request_response_funcs.go index 78ad61e41..8f92b3bc7 100644 --- a/transport/http/request_response_funcs.go +++ b/transport/http/request_response_funcs.go @@ -60,6 +60,7 @@ func PopulateRequestContext(ctx context.Context, r *http.Request) context.Contex ContextKeyRequestReferer: r.Header.Get("Referer"), ContextKeyRequestUserAgent: r.Header.Get("User-Agent"), ContextKeyRequestXRequestID: r.Header.Get("X-Request-Id"), + ContextKeyRequestAccept: r.Header.Get("Accept"), } { ctx = context.WithValue(ctx, k, v) } @@ -117,6 +118,10 @@ const ( // PopulateRequestContext. Its value is r.Header.Get("X-Request-Id"). ContextKeyRequestXRequestID + // ContextKeyRequestAccept is populated in the context by + // PopulateRequestContext. Its value is r.Header.Get("Accept"). + ContextKeyRequestAccept + // ContextKeyResponseHeaders is populated in the context whenever a // ServerFinalizerFunc is specified. Its value is of type http.Header, and // is captured only once the entire response has been written.