Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware is a function that takes a secret key as a parameter and returns a new function. This new function takes an http.Handler and returns another http.Handler that wraps the provided http.Handler. The returned http.Handler checks for a JWT token in the Authorization header of the HTTP request. If a token is found, it is parsed and the claims are added to the request context. If no token is found, the request is passed through to the next handler without modification. If the token is invalid, a 401 Unauthorized response is returned.
The secret parameter is used to validate the JWT token.
This function typically is used in an HTTP server to protect routes that require authentication.
Types ¶
This section is empty.