middleware

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	HeaderXRequestId  = "x-request-id"
	HeaderTraceParent = "traceparent"
	LogFieldRequestId = "requestID"
)
View Source
const (
	HttpServerMetricsRequestsCount    = "http_server_requests_total"
	HttpServerMetricsRequestsDuration = "http_server_requests_duration_seconds"
	HttpServerMetricsNotFoundPath     = "/not-found"
)

Variables

View Source
var DefaultRequestIdMiddlewareConfig = RequestIdMiddlewareConfig{
	Skipper:         middleware.DefaultSkipper,
	Generator:       uuid.NewDefaultUuidGenerator(),
	RequestIdHeader: echo.HeaderXRequestID,
}

DefaultRequestIdMiddlewareConfig is the default configuration for the RequestIdMiddleware.

View Source
var DefaultRequestLoggerMiddlewareConfig = RequestLoggerMiddlewareConfig{
	Skipper:                         middleware.DefaultSkipper,
	LogLevelFromResponseOrErrorCode: false,
	RequestHeadersToLog:             map[string]string{HeaderXRequestId: LogFieldRequestId},
	RequestUriPrefixesToExclude:     []string{},
}

DefaultRequestLoggerMiddlewareConfig is the default configuration for the RequestLoggerMiddleware.

View Source
var DefaultRequestMetricsMiddlewareConfig = RequestMetricsMiddlewareConfig{
	Skipper:                 middleware.DefaultSkipper,
	Registry:                prometheus.DefaultRegisterer,
	Namespace:               "",
	Subsystem:               "",
	Buckets:                 prometheus.DefBuckets,
	NormalizeRequestPath:    true,
	NormalizeResponseStatus: true,
}

DefaultRequestMetricsMiddlewareConfig is the default configuration for the RequestMetricsMiddleware.

View Source
var DefaultRequestTracerMiddlewareConfig = RequestTracerMiddlewareConfig{
	Skipper:                     middleware.DefaultSkipper,
	TracerProvider:              otel.GetTracerProvider(),
	TextMapPropagator:           propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}),
	RequestUriPrefixesToExclude: []string{},
}

DefaultRequestTracerMiddlewareConfig is the default configuration for the RequestTracerMiddleware.

Functions

func RequestIdMiddleware

func RequestIdMiddleware() echo.MiddlewareFunc

RequestIdMiddleware returns a RequestIdMiddleware with the DefaultRequestIdMiddlewareConfig.

func RequestIdMiddlewareWithConfig

func RequestIdMiddlewareWithConfig(config RequestIdMiddlewareConfig) echo.MiddlewareFunc

RequestIdMiddlewareWithConfig returns a RequestIdMiddleware for a provided RequestIdMiddlewareConfig.

func RequestLoggerMiddleware

func RequestLoggerMiddleware() echo.MiddlewareFunc

RequestLoggerMiddleware returns a RequestLoggerMiddleware with the DefaultRequestLoggerMiddlewareConfig.

func RequestLoggerMiddlewareWithConfig

func RequestLoggerMiddlewareWithConfig(config RequestLoggerMiddlewareConfig) echo.MiddlewareFunc

RequestLoggerMiddlewareWithConfig returns a RequestLoggerMiddleware for a provided RequestLoggerMiddlewareConfig.

func RequestMetricsMiddleware

func RequestMetricsMiddleware() echo.MiddlewareFunc

RequestMetricsMiddleware returns a RequestMetricsMiddleware with the DefaultRequestMetricsMiddlewareConfig.

func RequestMetricsMiddlewareWithConfig

func RequestMetricsMiddlewareWithConfig(config RequestMetricsMiddlewareConfig) echo.MiddlewareFunc

RequestMetricsMiddlewareWithConfig returns a RequestMetricsMiddleware for a provided RequestMetricsMiddlewareConfig.

func RequestTracerMiddleware

func RequestTracerMiddleware(serviceName string) echo.MiddlewareFunc

RequestTracerMiddleware returns a RequestTracerMiddleware with the DefaultRequestTracerMiddlewareConfig.

func RequestTracerMiddlewareWithConfig

func RequestTracerMiddlewareWithConfig(serviceName string, config RequestTracerMiddlewareConfig) echo.MiddlewareFunc

RequestTracerMiddlewareWithConfig returns a RequestTracerMiddleware for a provided RequestTracerMiddlewareConfig.

Types

type RequestIdMiddlewareConfig

type RequestIdMiddlewareConfig struct {
	Skipper         middleware.Skipper
	Generator       uuid.UuidGenerator
	RequestIdHeader string
}

RequestIdMiddlewareConfig is the configuration for the RequestIdMiddleware.

type RequestLoggerMiddlewareConfig

type RequestLoggerMiddlewareConfig struct {
	Skipper                         middleware.Skipper
	LogLevelFromResponseOrErrorCode bool
	RequestHeadersToLog             map[string]string
	RequestUriPrefixesToExclude     []string
}

RequestLoggerMiddlewareConfig is the configuration for the RequestLoggerMiddleware.

type RequestMetricsMiddlewareConfig

type RequestMetricsMiddlewareConfig struct {
	Skipper                 middleware.Skipper
	Registry                prometheus.Registerer
	Namespace               string
	Buckets                 []float64
	Subsystem               string
	NormalizeRequestPath    bool
	NormalizeResponseStatus bool
}

RequestMetricsMiddlewareConfig is the configuration for the RequestMetricsMiddleware.

type RequestTracerMiddlewareConfig

type RequestTracerMiddlewareConfig struct {
	Skipper                     middleware.Skipper
	TracerProvider              oteltrace.TracerProvider
	TextMapPropagator           propagation.TextMapPropagator
	RequestUriPrefixesToExclude []string
}

RequestTracerMiddlewareConfig is the configuration for the RequestTracerMiddleware.

Jump to

Keyboard shortcuts

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