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:
		
							parent
							
								
									b4a6313969
								
							
						
					
					
						commit
						dfac74a9e4
					
				
					 2 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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).
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue