// ExtractJWTFromHeader inspect the Authorization header for a Bearer token and
// if not present looks for a "JWT" cookie.
ExtractJWTFromHeader inspect the Authorization header for a Bearer token and
if not present looks for a "JWT" cookie.
// ExtractJWTFromHeader inspect the Authorization header for a Bearer token and // if not present looks for a " JWT " cookie .
func ExtractJWTFromHeader(r *http.Request) (jwt string, err error) {
	auth := r.Header.Get("Authorization")
	if auth == "" {
		jwtCookie, err := r.Cookie("JWT")
		if err != nil {
			return "", errors.New("Authorization not present in header")
		}
		jwt = jwtCookie.Value
	} else {
		auths := strings.Split(auth, " ")
		if len(auths) != 2 {
			return "", errors.Errorf("malformed Authorization header")
		}
		if !strings.EqualFold(auths[0], "Bearer") {
			return "", errors.Errorf("unknown Authorization method %s", auths[0])
		}
		jwt = auths[1]
	}
	return jwt, nil
}
func ExtractJWTFromHeader ( r * http . Request ) ( jwt string , err error ) { auth := r . Header . Get ( " " ) if auth == " " { jwtCookie , err := r . Cookie ( " " ) if err != nil { return " " , errors . New ( " " ) } jwt = jwtCookie . Value } else { auths := strings . Split ( auth , " " ) if len ( auths ) != 2 { return " " , errors . Errorf ( " " ) } if ! strings . EqualFold ( auths [ 0 ] , " " ) { return " " , errors . Errorf ( " " , auths [ 0 ] ) } jwt = auths [ 1 ] } return jwt , nil }
ExtractJWTFromHeader inspect the Authorization header for a Bearer token and
if not present looks for a "JWT" cookie.
ExtractJWTFromHeader inspect the Authorization header for a Bearer token and if not present looks for a " JWT " cookie .