Skip to content

Commit

Permalink
feat: add content path in request context
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Feb 24, 2023
1 parent 6c0f842 commit b940fa6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ type RequestContextKey string
const (
DNSLinkHostnameKey RequestContextKey = "dnslink-hostname"
GatewayHostnameKey RequestContextKey = "gw-hostname"
ContentPathKey RequestContextKey = "content-path"
)
2 changes: 2 additions & 0 deletions gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ func (i *handler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) {
}

contentPath := ipath.New(r.URL.Path)
ctx := context.WithValue(r.Context(), ContentPathKey, contentPath)
r = r.WithContext(ctx)

if requestHandled := i.handleOnlyIfCached(w, r, contentPath, logger); requestHandled {
return
Expand Down

0 comments on commit b940fa6

Please sign in to comment.