- import the package using the commands in your project
import (
"github.com/zblocks/middleware-lib"
)
Inside terminal run
go get github.com/zblocks/middleware-lib
- Functions included in the library
func VerifyJwtToken(c *gin.Context, jwtSecret string) (bool, jwt.MapClaims, int, error)
func SetCors(r *gin.Engine)
- Variables defined in the library
var ErrAuthorizationTokenEmpty = 20003
var ErrAuthorizationTokenInvalid = 20004
var AuthorizationTokenEmpty = "authorization token not provided"
var AuthorizationTokenInvalid = "authorization token invalid"
- In your test function replace MiddlewareHandler interface with the mock interface
middleware.MiddlewareHandler = middlewareMock.MiddlewareMock
- Define mocking behavior for the function
middlewareMock.MiddlewareMock.On("VerifyJwtTokenV2", mock.AnythingOfType("*gin.Context"), "<auth_service_base_url>").Return(true)