X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e6617f0bff3521135bc63b229260fdfb7b9dc331..617d783980943ac7cda84d94a5a43e06adeb838e:/sdk/go/auth/handlers.go diff --git a/sdk/go/auth/handlers.go b/sdk/go/auth/handlers.go index 9fa501ab7a..b638f79825 100644 --- a/sdk/go/auth/handlers.go +++ b/sdk/go/auth/handlers.go @@ -9,17 +9,15 @@ import ( "net/http" ) -type contextKey string - -var ContextKeyCredentials contextKey = "credentials" +type contextKeyCredentials struct{} // LoadToken wraps the next handler, adding credentials to the request // context so subsequent handlers can access them efficiently via // CredentialsFromRequest. func LoadToken(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if _, ok := r.Context().Value(ContextKeyCredentials).(*Credentials); !ok { - r = r.WithContext(context.WithValue(r.Context(), ContextKeyCredentials, CredentialsFromRequest(r))) + if _, ok := r.Context().Value(contextKeyCredentials{}).(*Credentials); !ok { + r = r.WithContext(context.WithValue(r.Context(), contextKeyCredentials{}, CredentialsFromRequest(r))) } next.ServeHTTP(w, r) })