mw

package
v0.0.0-...-7e06a17 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const CorrelatorHTTPHeader = "Unica-Correlator"

CorrelatorHTTPHeader is the HTTP header name to store the correlator.

Variables

This section is empty.

Functions

func CorrelatorHandler

func CorrelatorHandler(next http.Handler) http.Handler

CorrelatorHandler registers the correlator and transactionID in the application context. It generates a transactionID (as a UUID). It also obtains the correlator from a HTTP header. If the header is not available, the correlator is set to the transactionID. It also adds a HTTP header with the correlator in the response.

func InitAppCtxHandler

func InitAppCtxHandler(next http.Handler) http.Handler

InitAppCtxHandler is a middleware to initialize the ApplicationContext in the standard context.

func InitLogCtxHandler

func InitLogCtxHandler(logger *zerolog.Logger) func(next http.Handler) http.Handler

InitLogCtxHandler is a middleware to initialize the LogContext in the standard context.

func LogContextHandler

func LogContextHandler(op string) func(http.Handler) http.Handler

LogContextHandler is a middleware to update the logger with a context using the operation and the current ApplicationContext in the Context.

func LogHTTPHandler

func LogHTTPHandler(next http.Handler) http.Handler

LogHTTPHandler is a middleware to log the HTTP request and response.

func MethodsHandler

func MethodsHandler(methods ...string) func(next http.Handler) http.Handler

MethodsHandler is a middleware to filter incoming HTTP request by its method.

func SecurityHandler

func SecurityHandler(securitySvc service.SessionsService) func(next http.Handler) http.Handler

SecurityHandler is a middleware to filter incoming HTTP request returning 401 if not authenticated.

Types

type LoggableResponseWriter

type LoggableResponseWriter struct {
	Status int
	http.ResponseWriter
}

LoggableResponseWriter is a ResponseWriter wrapper to log the response status code.

func (*LoggableResponseWriter) WriteHeader

func (w *LoggableResponseWriter) WriteHeader(statusCode int)

WriteHeader overwrites ResponseWriter's WriteHeader to store the response status code.

Jump to

Keyboard shortcuts

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