middleware

package
v2.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultLoggerConfig is the default Logger middleware config.
	DefaultLoggerConfig = LoggerConfig{
		Skipper:          middleware.DefaultSkipper,
		AccessLogFormat:  accessLogFormat,
		BodyDumpFormat:   bodyDumpFormat,
		CustomTimeFormat: "2006-01-02 15:04:05.00000",
		// contains filtered or unexported fields
	}
)

Functions

func AccessLoggerWithConfig

func AccessLoggerWithConfig(config LoggerConfig) echo.MiddlewareFunc

AccessLoggerWithConfig returns a Logger middleware with config.

func MethodNotAllowedAndRouteNotFound

func MethodNotAllowedAndRouteNotFound() echo.MiddlewareFunc

MethodNotAllowedAndRouteNotFound middleware will reply HTTP 405 if a wrong method been called for an API route. This middleware will also return 404 if a page doesn't exist.

func ServerHeader

func ServerHeader(name, version string) echo.MiddlewareFunc

ServerHeader middleware adds a `Server` header to the response.

func Tracer

func Tracer() echo.MiddlewareFunc

Tracer attach a root sentry span context to the request.

Types

type LoggerConfig

type LoggerConfig struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper

	// Optional. Default value DefaultLoggerConfig.AccessLogFormat.
	AccessLogFormat string `yaml:"format"`

	// Optional. Default value DefaultLoggerConfig.BodyDumpFormat.
	BodyDumpFormat string `yaml:"format"`

	// Optional. Default value DefaultLoggerConfig.CustomTimeFormat.
	CustomTimeFormat string `yaml:"custom_time_format"`

	// Output is a writer where logs in JSON format are written.
	// Optional. Default value os.Stdout.
	Output io.Writer

	// BodyDump is an option to control the log also print the request and response body.
	// Optional. Default value false.
	BodyDump bool

	// MaskedParameters is a slice of parameters for which the user wants to mask the value in logs.
	// Optional. Default value [].
	MaskedParameters []string

	// RequestHeader is a slice of HTTP request header parameters which user wants to log.
	RequestHeader []string
	// contains filtered or unexported fields
}

LoggerConfig defines the config for Logger middleware.

Jump to

Keyboard shortcuts

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