Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -11,8 +11,10 @@ import ( |
| 11 | 11 |
"golang.org/x/net/context" |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 |
+type contextKey string |
|
| 15 |
+ |
|
| 14 | 16 |
// APIVersionKey is the client's requested API version. |
| 15 |
-const APIVersionKey = "api-version" |
|
| 17 |
+const APIVersionKey contextKey = "api-version" |
|
| 16 | 18 |
|
| 17 | 19 |
// APIFunc is an adapter to allow the use of ordinary functions as Docker API endpoints. |
| 18 | 20 |
// Any function that has the appropriate signature can be registered as an API endpoint (e.g. getVersion). |
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"net/http" |
| 6 | 6 |
"runtime" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/api/server/httputils" |
|
| 8 | 9 |
"github.com/docker/docker/api/types/versions" |
| 9 | 10 |
"golang.org/x/net/context" |
| 10 | 11 |
) |
| ... | ... |
@@ -57,8 +58,7 @@ func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http. |
| 57 | 57 |
if versions.GreaterThan(apiVersion, v.defaultVersion) {
|
| 58 | 58 |
return versionUnsupportedError{version: apiVersion, maxVersion: v.defaultVersion}
|
| 59 | 59 |
} |
| 60 |
- // nolint: golint |
|
| 61 |
- ctx = context.WithValue(ctx, "api-version", apiVersion) |
|
| 60 |
+ ctx = context.WithValue(ctx, httputils.APIVersionKey, apiVersion) |
|
| 62 | 61 |
return handler(ctx, w, r, vars) |
| 63 | 62 |
} |
| 64 | 63 |
|