summaryrefslogtreecommitdiff
path: root/api/server/httputils
diff options
context:
space:
mode:
authorzteBill <bi.zhenkun@zte.com.cn>2016-11-15 01:15:24 +0800
committerzteBill <bi.zhenkun@zte.com.cn>2016-11-17 17:13:25 +0800
commit4b3a1bbda5613ee12d4e94f7797fca51139109a6 (patch)
tree211176672babf17ba60c49136e8f8ef8d4beae22 /api/server/httputils
parenta5dce0cb1ac70924d5f2d8b9e146eee492c2fb5b (diff)
downloaddocker-4b3a1bbda5613ee12d4e94f7797fca51139109a6.tar.gz
make each return explicitly
Signed-off-by: zteBill <bi.zhenkun@zte.com.cn>
Diffstat (limited to 'api/server/httputils')
-rw-r--r--api/server/httputils/httputils.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/api/server/httputils/httputils.go b/api/server/httputils/httputils.go
index 7930ff7a07..d37ee5cafe 100644
--- a/api/server/httputils/httputils.go
+++ b/api/server/httputils/httputils.go
@@ -78,13 +78,14 @@ func ParseForm(r *http.Request) error {
// VersionFromContext returns an API version from the context using APIVersionKey.
// It panics if the context value does not have version.Version type.
-func VersionFromContext(ctx context.Context) (ver string) {
+func VersionFromContext(ctx context.Context) string {
if ctx == nil {
- return
+ return ""
}
- val := ctx.Value(APIVersionKey)
- if val == nil {
- return
+
+ if val := ctx.Value(APIVersionKey); val != nil {
+ return val.(string)
}
- return val.(string)
+
+ return ""
}