diff --git a/components/engine/api/server/httputils/httputils.go b/components/engine/api/server/httputils/httputils.go index 57eeb4beba..47b82ef1ba 100644 --- a/components/engine/api/server/httputils/httputils.go +++ b/components/engine/api/server/httputils/httputils.go @@ -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). diff --git a/components/engine/api/server/middleware/version.go b/components/engine/api/server/middleware/version.go index 679552910f..c3e289cd49 100644 --- a/components/engine/api/server/middleware/version.go +++ b/components/engine/api/server/middleware/version.go @@ -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) }