web

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(secret []byte) func(next http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL