middleware

package
v0.0.0-...-1c68573 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentUserContextKey = "current_user"

Variables

This section is empty.

Functions

This section is empty.

Types

type JWT

type JWT struct {
	// contains filtered or unexported fields
}

JWT is a middleware which validates, verifies JSON Web Token provided through an authorization header. It also handles all possible exceptions and, in case of valid request, fetches user, associated with the provided JWT and transfers it to the next handler through CurrentUserContextKey context key.

func NewJWT

func NewJWT(db database.Database, jwtAuth auth.JWTAuthenticator, errLogger *log.Logger) *JWT

NewJWT creates a new JWT and returns pointer to it.

func (*JWT) Middleware

func (m *JWT) Middleware() MiddlewareFunc

type MiddlewareFunc

type MiddlewareFunc func(next http.Handler) http.Handler

MiddlewareFunc is a which is a middleware: it receives an HTTP handler, and returns an HTTP handler which performs some operations and optionally calls the provided handler.

type Middlewarer

type Middlewarer interface {
	// Middleware must return a middleware function which can be used to wrap handlers.
	Middleware() MiddlewareFunc
}

Middlewarer describes a structure which holds a middleware.

Jump to

Keyboard shortcuts

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