1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Golint: don't use basic untyped string for context key

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-01-15 00:43:49 +01:00
parent b4a6313969
commit dfac74a9e4
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 5 additions and 3 deletions

View file

@ -11,8 +11,10 @@ import (
"golang.org/x/net/context"
)
type contextKey string
// APIVersionKey is the client's requested API version.
const APIVersionKey = "api-version"
const APIVersionKey contextKey = "api-version"
// APIFunc is an adapter to allow the use of ordinary functions as Docker API endpoints.
// Any function that has the appropriate signature can be registered as an API endpoint (e.g. getVersion).

View file

@ -5,6 +5,7 @@ import (
"net/http"
"runtime"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types/versions"
"golang.org/x/net/context"
)
@ -57,8 +58,7 @@ func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.
if versions.GreaterThan(apiVersion, v.defaultVersion) {
return versionUnsupportedError{version: apiVersion, maxVersion: v.defaultVersion}
}
// nolint: golint
ctx = context.WithValue(ctx, "api-version", apiVersion)
ctx = context.WithValue(ctx, httputils.APIVersionKey, apiVersion)
return handler(ctx, w, r, vars)
}