middleware

package
v0.0.0-...-1d6e856 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package middleware provides HTTP handler useful decorators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessLog

func AccessLog(next http.Handler, logger xlog.Logger, opts ...AccessLogOpts) http.Handler

AccessLog is a decorator/middleware that extracts/ads a correlation id from/to request/response.

func ContextWithLogger

func ContextWithLogger(next http.Handler, logger xlog.Logger) http.Handler

ContextWithLogger is a decorator/middleware that sets the logger on request context.

func CorrelationID

func CorrelationID(next http.Handler, makeCorrelationID xtransport.CorrelationIDFactory) http.Handler

CorrelationID is a decorator/middleware that extracts/ads a correlation id from/to request/response.

func Recover

func Recover(next http.Handler, logger xlog.Logger) http.Handler

Recover is a decorator/middleware that gracefully logs any panic occurred while serving a request.

Types

type AccessLogOpts

type AccessLogOpts struct {
	// SkipMethods specifies the http methods to skip logging for.
	SkipMethods []string
	// ObfuscatePathValues specifies the request url parts that should be obscure.
	// Last maximum 8 chars from it will be replaced with "*".
	ObfuscatePathValues []string
}

AccessLogOpts holds some configuration for access log.

Jump to

Keyboard shortcuts

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