Skip to content

Commit 35c6e6c

Browse files
committed
fix: solved 'm.handler.HandleErrorResponse undefined' error
1 parent a6207f9 commit 35c6e6c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

http/middleware/auth/middleware.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
gojwtinterception "github.com/ralvarezdev/go-jwt/token/interception"
88
gojwtvalidator "github.com/ralvarezdev/go-jwt/token/validator"
99
gonethttp "github.com/ralvarezdev/go-net/http"
10-
gonethttpresponse "github.com/ralvarezdev/go-net/http/handler"
10+
gonethttphandler "github.com/ralvarezdev/go-net/http/handler"
1111
gonethttpjwtvalidator "github.com/ralvarezdev/go-net/http/jwt/validator"
1212
"net/http"
1313
"strings"
@@ -16,22 +16,22 @@ import (
1616
// Middleware struct
1717
type Middleware struct {
1818
validator gojwtvalidator.Validator
19-
handler gonethttpresponse.Handler
19+
handler gonethttphandler.Handler
2020
jwtValidatorErrorHandler gonethttpjwtvalidator.ErrorHandler
2121
}
2222

2323
// NewMiddleware creates a new authentication middleware
2424
func NewMiddleware(
2525
validator gojwtvalidator.Validator,
26-
handler gonethttpresponse.Handler,
26+
handler gonethttphandler.Handler,
2727
jwtValidatorErrorHandler gonethttpjwtvalidator.ErrorHandler,
2828
) (*Middleware, error) {
2929
// Check if either the validator, response handler or validator handler is nil
3030
if validator == nil {
3131
return nil, gojwtvalidator.ErrNilValidator
3232
}
3333
if handler == nil {
34-
return nil, gonethttpresponse.ErrNilHandler
34+
return nil, gonethttphandler.ErrNilHandler
3535
}
3636
if jwtValidatorErrorHandler == nil {
3737
return nil, gonethttpjwtvalidator.ErrNilErrorHandler
@@ -60,9 +60,9 @@ func (m *Middleware) Authenticate(
6060
// Parse the authorization to a string
6161
authorizationStr, ok := authorization.(string)
6262
if !ok {
63-
m.handler.HandleErrorResponse(
63+
m.handler.HandleResponse(
6464
w,
65-
gonethttpresponse.NewErrorResponseWithCode(
65+
gonethttphandler.NewErrorResponseWithCode(
6666
gonethttp.ErrInvalidAuthorizationHeader,
6767
http.StatusUnauthorized,
6868
),
@@ -75,9 +75,9 @@ func (m *Middleware) Authenticate(
7575

7676
// Return an error if the authorization is missing or invalid
7777
if len(parts) < 2 || parts[0] != gojwt.BearerPrefix {
78-
m.handler.HandleErrorResponse(
78+
m.handler.HandleResponse(
7979
w,
80-
gonethttpresponse.NewErrorResponseWithCode(
80+
gonethttphandler.NewErrorResponseWithCode(
8181
gonethttp.ErrInvalidAuthorizationHeader,
8282
http.StatusUnauthorized,
8383
),

0 commit comments

Comments
 (0)