middleware

package
v0.0.0-...-e38db06 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Correlation

func Correlation(c *CorrelationConfig) func(http.Handler) http.Handler

Correlation

func NotFound

func NotFound(next http.Handler) http.Handler

NotFound

func RequestLogger

func RequestLogger(c *RequestLoggerConfig) func(http.Handler) http.Handler

RequestLogger returns the request logger middleware

func ResponseLogger

func ResponseLogger(c *ResponseLoggerConfig) func(http.Handler) http.Handler

ResponseLogger returns the response logger middleware

Types

type CorrelationConfig

type CorrelationConfig struct {
	// ContextKey for storing correlation data in context locals
	ContextKey trace.ContextKey

	// Generator defines a function to generate request identifier
	Generator func() string

	// Header key for trace ID get/set
	Header string

	// Next defines a function to skip this middleware on return true
	Next func(r *http.Request) bool
}

CorrelationConfig

type RequestLogData

type RequestLogData struct {
	Body     map[string]any
	ClientIP string
	Headers  http.Header
	Method   string
	Path     string
}

RequestLogData defines the data captured for request logging

type RequestLoggerConfig

type RequestLoggerConfig struct {
	Logger *cl.CustomLogger `validate:"required"`
	Next   func(r *http.Request) bool
}

RequestLoggerConfig defines necessary components for the request logger middleware

type ResponseLogData

type ResponseLogData struct {
	Body         map[string]any
	BodySize     *int
	Headers      http.Header
	ResponseTime string
	Status       int
}

ResponseLogData defines the data captured for response logging

type ResponseLoggerConfig

type ResponseLoggerConfig struct {
	Logger *cl.CustomLogger `validate:"required"`
	Next   func(r *http.Request) bool
}

ResponseLoggerConfig defines necessary components for the response logger middleware

Jump to

Keyboard shortcuts

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