mirror of https://github.com/golang-jwt/jwt.git
moved request related error int request subpackage
This commit is contained in:
parent
288cee4336
commit
070a4bdd00
|
@ -6,9 +6,8 @@ import (
|
||||||
|
|
||||||
// Error constants
|
// Error constants
|
||||||
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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue