minor cleanup

- Reused contains() from utils.go at a couple of places
- Cleanup in return statements and boolean checks
This commit is contained in:
Mohit Agarwal
2016-08-16 20:27:14 +05:30
committed by Harshavardhana
parent ec4260d260
commit 418921de89
10 changed files with 20 additions and 51 deletions

View File

@@ -165,22 +165,18 @@ func setAuthHandler(h http.Handler) http.Handler {
}
// List of all support S3 auth types.
var supportedS3AuthTypes = []authType{
authTypeAnonymous,
authTypePresigned,
authTypeSigned,
authTypePostPolicy,
authTypeStreamingSigned,
var supportedS3AuthTypes = map[authType]struct{}{
authTypeAnonymous: {},
authTypePresigned: {},
authTypeSigned: {},
authTypePostPolicy: {},
authTypeStreamingSigned: {},
}
// Validate if the authType is valid and supported.
func isSupportedS3AuthType(aType authType) bool {
for _, a := range supportedS3AuthTypes {
if a == aType {
return true
}
}
return false
_, ok := supportedS3AuthTypes[aType]
return ok
}
// handler for validating incoming authorization headers.