X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/70459cdae1f4e92789a14c1fecb66f5954a5aa7f..bf08477c7e766c7692731c08212c8d1c3c5628ea:/sdk/go/auth/handlers.go diff --git a/sdk/go/auth/handlers.go b/sdk/go/auth/handlers.go index ad1fa5141a..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) })