-
Notifications
You must be signed in to change notification settings - Fork 260
Open
Labels
Description
Line 244 in 21707c0
switch possibleSlice.(type) { |
if the first argument to pass type type MapClaims map[string]interface{}
example how here:
if !sliceContainsStr(tokenClaims[JWT_ENDPOINTS_ATTR], url) {
http.Error(w, "", http.StatusUnauthorized)
return
It switch possibleSlice.(type) {
will return interface{}
accordingly, the function will never return true
func sliceContainsStr(possibleSlice interface{}, str string) bool {
switch possibleSlice.(type) {
case []string:
for _, elem := range possibleSlice.([]string) {
if elem == str {
return true
}
}
}
return false
}
I suggest so:
func sliceContainsStr(possibleSlice interface{}, str string) bool {
if possibleSlice, exist := possibleSlice.([]string); exist {
for _, elem := range possibleSlice {
if elem == str {
return true
}
}
}
return false
}
HouzuoGuo