middleware

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 12 Imported by: 0

README

Middleware Package

The official documentation of the Middleware package will be here.

Documentation

Index

Constants

View Source
const (
	ContextKeyRemoteAddr = "remoteAddr"
	ContextKeyRequestID  = "requestID"
	ContextKeyJwtID      = "jwtID"
	ContextKeyJwtData    = "jwtData"
)

Variables

This section is empty.

Functions

func NewContextGetter

func NewContextGetter() *contextGetter

func NewMiddleware

func NewMiddleware(
	config ConfigMiddleware,
	jwtAccess jwt.Jwt,
	dataAccess secretdata.SecretData) *middleware

Types

type ConfigMiddleware

type ConfigMiddleware struct {
	RequestIDRequired bool
	RequestIDCheck    bool
}

type ContextGetter

type ContextGetter interface {
	GetRemoteAddr(ctx context.Context) (string, string, error)
	GetRequestID(ctx context.Context) (string, string, error)
	GetJwtID(ctx context.Context) (string, error)
	GetJwtData(ctx context.Context) ([]byte, error)
}

type Middleware

type Middleware interface {
	RequestID(logger *zap.Logger) func(http.Handler) http.Handler
	RemoteAddr(logger *zap.Logger) func(http.Handler) http.Handler
	Logging(logger *zap.Logger) func(http.Handler) http.Handler
	Authorization(logger *zap.Logger) func(http.Handler) http.Handler
}

type MockDescription

type MockDescription struct {
	Props    struct{}
	Expected struct {
		Error error
	}
}
var MockData MockDescription

func (*MockDescription) GetJwtData

func (s *MockDescription) GetJwtData(_ context.Context) ([]byte, error)

func (*MockDescription) GetJwtID

func (s *MockDescription) GetJwtID(_ context.Context) (string, error)

func (*MockDescription) GetRemoteAddr

func (s *MockDescription) GetRemoteAddr(_ context.Context) (string, string, error)

func (*MockDescription) GetRequestID

func (s *MockDescription) GetRequestID(_ context.Context) (string, string, error)

Jump to

Keyboard shortcuts

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