Documentation ¶
Index ¶
- Constants
- func CorrelatorHandler(next http.Handler) http.Handler
- func InitAppCtxHandler(next http.Handler) http.Handler
- func InitLogCtxHandler(logger *zerolog.Logger) func(next http.Handler) http.Handler
- func LogContextHandler(op string) func(http.Handler) http.Handler
- func LogHTTPHandler(next http.Handler) http.Handler
- func MethodsHandler(methods ...string) func(next http.Handler) http.Handler
- func SecurityHandler(securitySvc service.SessionsService) func(next http.Handler) http.Handler
- type LoggableResponseWriter
Constants ¶
const CorrelatorHTTPHeader = "Unica-Correlator"
CorrelatorHTTPHeader is the HTTP header name to store the correlator.
Variables ¶
This section is empty.
Functions ¶
func CorrelatorHandler ¶
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 ¶
InitAppCtxHandler is a middleware to initialize the ApplicationContext in the standard context.
func InitLogCtxHandler ¶
InitLogCtxHandler is a middleware to initialize the LogContext in the standard context.
func LogContextHandler ¶
LogContextHandler is a middleware to update the logger with a context using the operation and the current ApplicationContext in the Context.
func LogHTTPHandler ¶
LogHTTPHandler is a middleware to log the HTTP request and response.
func MethodsHandler ¶
MethodsHandler is a middleware to filter incoming HTTP request by its method.
func SecurityHandler ¶
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.