middleware

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 13 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"
	ContextKeyJwt        = "jwt"
)

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
	ContainsJwtAudience string
	DecryptJwtData      bool
	DevelopmentMode     bool
}

type ContextGetter

type ContextGetter interface {
	GetRemoteAddr(ctx context.Context) (string, string, error)
	GetRequestId(ctx context.Context) (string, string, error)
	GetJwt(ctx context.Context) (jwt.Token, 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 {
	Expected struct {
		GetRemoteAddr struct {
			ContextValue string
			ContextKey   string
			Error        error
		}
		GetRequestId struct {
			ContextValue string
			ContextKey   string
			Error        error
		}
		GetJwt struct {
			Token jwt.Token
			Error error
		}
	}
}
var Mock MockDescription

func (*MockDescription) GetJwt added in v0.1.6

func (s *MockDescription) GetJwt(_ context.Context) (jwt.Token, error)

func (*MockDescription) GetRemoteAddr

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

func (*MockDescription) GetRequestId added in v0.1.14

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