middleware

package
v0.0.0-...-e6e2e8d Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package middleware implements common middlewares for http handlers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// AuthHeaderKey is the key for authorization header.
	AuthHeaderKey = "authorization"
	// AuthTypeBearer is the type of athorization token.
	AuthTypeBearer = "bearer"
	// AuthPayloadKey is the key for authorization payload.
	AuthPayloadKey = "authorization_payload"
	// ErrAuthHeaderNotFound indicates that an authorization header is not found.
	ErrAuthHeaderNotFound = errors.New("authorization header is not found")
	// ErrBadAuthHeaderFormat indicates invalid authorization header format.
	ErrBadAuthHeaderFormat = errors.New("invalid authorization header format")
	// ErrUnsupportedAuthType indicates unsupported authorization type.
	ErrUnsupportedAuthType = errors.New("unsupported authorization type")
)

Functions

func AddAuthorization

func AddAuthorization(r *http.Request, tm tokenpkg.Maker, authType string, username string, d time.Duration) error

AddAuthorization sets authorization token to the given request.

func AuthMiddleware

func AuthMiddleware(tokenMaker tokenpkg.Maker) gin.HandlerFunc

AuthMiddleware verifies request authorization token.

func CreateLogger

func CreateLogger(config configpkg.Config) zerolog.Logger

CreateLogger returns logger depending on config environement.

func RequestLogger

func RequestLogger(logger zerolog.Logger) gin.HandlerFunc

RequestLogger logs a gin HTTP request in JSON format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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