6 "github.com/google/uuid"
7 "github.com/justinas/alice"
8 middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
11func NewScope(reverseProxy bool, idHeader string) alice.Constructor {
12 return func(next http.Handler) http.Handler {
13 return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
14 scope := &middlewareapi.RequestScope{
15 ReverseProxy: reverseProxy,
16 RequestID: genRequestID(req, idHeader),
18 req = middlewareapi.AddRequestScope(req, scope)
19 next.ServeHTTP(rw, req)
24// genRequestID sets a request-wide ID for use in logging or error pages.
25// If a RequestID header is set, it uses that. Otherwise, it generates a random
26// UUID for the lifespan of the request.
27func genRequestID(req *http.Request, idHeader string) string {
28 rid := req.Header.Get(idHeader)
32 return uuid.New().String()
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