7 "github.com/justinas/alice"
8 middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
13// requestScopeKey uses a typed string to reduce likelihood of clasing
14// with other context keys
15const requestScopeKey scopeKey = "request-scope"
17func NewScope() alice.Constructor {
21// addScope injects a new request scope into the request context.
22func addScope(next http.Handler) http.Handler {
23 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
24 scope := &middlewareapi.RequestScope{}
25 contextWithScope := context.WithValue(req.Context(), requestScopeKey, scope)
26 requestWithScope := req.WithContext(contextWithScope)
27 next.ServeHTTP(rw, requestWithScope)
31// GetRequestScope returns the current request scope from the given request
32func GetRequestScope(req *http.Request) *middlewareapi.RequestScope {
33 scope := req.Context().Value(requestScopeKey)
38 return scope.(*middlewareapi.RequestScope)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list