File tree Expand file tree Collapse file tree 4 files changed +20
-23
lines changed
Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -2,15 +2,9 @@ package http
22
33import (
44 "errors"
5- gojwtnethttp "github.com/ralvarezdev/go-jwt/net/http"
6- gonethttpresponse "github.com/ralvarezdev/go-net/http/response"
75)
86
97var (
10- ErrNilRequestBody = errors .New ("request body cannot be nil" )
11- ErrInDevelopment = errors .New ("in development" )
12- ErrInvalidAuthorizationHeader = gonethttpresponse .NewHeaderError (
13- gojwtnethttp .AuthorizationHeaderKey ,
14- "invalid authorization header" ,
15- )
8+ ErrNilRequestBody = errors .New ("request body cannot be nil" )
9+ ErrInDevelopment = errors .New ("in development" )
1610)
Original file line number Diff line number Diff line change @@ -31,20 +31,16 @@ func bodyDecodeErrorHandler(
3131 if fieldName != "" {
3232 return encoder .Encode (
3333 w ,
34- gonethttpresponse .NewDebugFailResponse (
35- gonethttpresponse .NewRequestErrorsBodyData (
36- gonethttpresponse .NewFieldError (
37- fieldName ,
38- fmt .Sprintf (
39- ErrFieldInvalidValue ,
40- fieldTypeName ,
41- fieldValue ,
42- ),
34+ gonethttpresponse .NewFailResponseFromRequestError (
35+ gonethttpresponse .NewFieldError (
36+ fieldName ,
37+ fmt .Sprintf (
38+ ErrFieldInvalidValue ,
39+ fieldTypeName ,
40+ fieldValue ,
4341 ),
42+ http .StatusBadRequest ,
4443 ),
45- err ,
46- nil ,
47- http .StatusBadRequest ,
4844 ),
4945 )
5046 }
Original file line number Diff line number Diff line change @@ -2,8 +2,16 @@ package auth
22
33import (
44 "errors"
5+ gojwtnethttp "github.com/ralvarezdev/go-jwt/net/http"
6+ gonethttpresponse "github.com/ralvarezdev/go-net/http/response"
7+ "net/http"
58)
69
710var (
8- ErrNilAuthenticator = errors .New ("authenticator cannot be nil" )
11+ ErrNilAuthenticator = errors .New ("authenticator cannot be nil" )
12+ ErrInvalidAuthorizationHeader = gonethttpresponse .NewHeaderError (
13+ gojwtnethttp .AuthorizationHeaderKey ,
14+ "invalid authorization header" ,
15+ http .StatusUnauthorized ,
16+ )
917)
Original file line number Diff line number Diff line change 66 gojwtnethttpctx "github.com/ralvarezdev/go-jwt/net/http/context"
77 gojwtinterception "github.com/ralvarezdev/go-jwt/token/interception"
88 gojwtvalidator "github.com/ralvarezdev/go-jwt/token/validator"
9- gonethttp "github.com/ralvarezdev/go-net/http"
109 gonethttphandler "github.com/ralvarezdev/go-net/http/handler"
1110 gonethttpjwtvalidator "github.com/ralvarezdev/go-net/http/jwt/validator"
1211 "net/http"
@@ -61,7 +60,7 @@ func (m *Middleware) Authenticate(
6160 if len (parts ) < 2 || parts [0 ] != gojwt .BearerPrefix {
6261 m .jwtValidatorFailHandler (
6362 w ,
64- gonethttp . ErrInvalidAuthorizationHeader ,
63+ ErrInvalidAuthorizationHeader ,
6564 )
6665 return
6766 }
You can’t perform that action at this time.
0 commit comments