Skip to content

Commit

Permalink
transport/http: PopulateRequestContext Accept
Browse files Browse the repository at this point in the history
Add the request Accept header to the context,
under the ContextKeyRequestAccept key.

Closes #515.
  • Loading branch information
peterbourgon committed Apr 19, 2017
1 parent d0853ee commit b174c0e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions transport/http/request_response_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b174c0e

Please sign in to comment.