moved request related error int request subpackage

This commit is contained in:
Dave Grijalva 2016-04-08 13:58:29 -07:00
parent 288cee4336
commit 070a4bdd00
2 changed files with 9 additions and 4 deletions

View File

@ -8,7 +8,6 @@ import (
var ( var (
ErrInvalidKey = errors.New("key is invalid or of invalid type") ErrInvalidKey = errors.New("key is invalid or of invalid type")
ErrHashUnavailable = errors.New("the requested hash function is unavailable") ErrHashUnavailable = errors.New("the requested hash function is unavailable")
ErrNoTokenInRequest = errors.New("no token present in request")
) )
// The errors that might occur when parsing and validating a token // The errors that might occur when parsing and validating a token

View File

@ -1,11 +1,17 @@
package request package request
import ( import (
"errors"
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
"net/http" "net/http"
"strings" "strings"
) )
// Errors
var (
ErrNoTokenInRequest = errors.New("no token present in request")
)
// Try to find the token in an http.Request. // Try to find the token in an http.Request.
// This method will call ParseMultipartForm if there's no token in the header. // This method will call ParseMultipartForm if there's no token in the header.
// Currently, it looks in the Authorization header as well as // Currently, it looks in the Authorization header as well as
@ -29,5 +35,5 @@ func ParseFromRequestWithClaims(req *http.Request, keyFunc jwt.Keyfunc, claims j
return jwt.ParseWithClaims(tokStr, keyFunc, claims) return jwt.ParseWithClaims(tokStr, keyFunc, claims)
} }
return nil, jwt.ErrNoTokenInRequest return nil, ErrNoTokenInRequest
} }