From 070a4bdd003267a775ae94172aeb3fba45f1b309 Mon Sep 17 00:00:00 2001 From: Dave Grijalva Date: Fri, 8 Apr 2016 13:58:29 -0700 Subject: [PATCH] moved request related error int request subpackage --- errors.go | 5 ++--- request/request.go | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/errors.go b/errors.go index b055f3b..6a60e91 100644 --- a/errors.go +++ b/errors.go @@ -6,9 +6,8 @@ import ( // Error constants var ( - ErrInvalidKey = errors.New("key is invalid or of invalid type") - ErrHashUnavailable = errors.New("the requested hash function is unavailable") - ErrNoTokenInRequest = errors.New("no token present in request") + ErrInvalidKey = errors.New("key is invalid or of invalid type") + ErrHashUnavailable = errors.New("the requested hash function is unavailable") ) // The errors that might occur when parsing and validating a token diff --git a/request/request.go b/request/request.go index c1ba852..c812488 100644 --- a/request/request.go +++ b/request/request.go @@ -1,11 +1,17 @@ package request import ( + "errors" "github.com/dgrijalva/jwt-go" "net/http" "strings" ) +// Errors +var ( + ErrNoTokenInRequest = errors.New("no token present in request") +) + // Try to find the token in an http.Request. // This method will call ParseMultipartForm if there's no token in the header. // 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 nil, jwt.ErrNoTokenInRequest + return nil, ErrNoTokenInRequest }