middleware

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// HTTPResponseLatencyKey is the amount of time needed to produce a response to a request.
	HTTPResponseLatencyKey = "http.response_latency"
)

Variables

This section is empty.

Functions

func Default

func Default(in DefaultInput) []gin.HandlerFunc

Default returns a list of middlewares usually used by most applications. It includes: - Disaster Recovery (from panics) - Traces - Metrics - Request Logging - Error Handling

func ErrorHandler

func ErrorHandler(ctx *gin.Context)

ErrorHandler handles request errors, standardizing how error responses payloads should be served.

func Logger

func Logger(logger LogProvider) func(ctx *gin.Context)

Logger creates a new Logger middleware that uses Trivela's GoKit default logger.

func Meter

func Meter(applicationName string) func(ctx *gin.Context)

Meter creates a new Meter middleware that measures application performance.

Types

type DefaultInput

type DefaultInput struct {
	ApplicationName string
	Logger          LogProvider
}

DefaultInput encapsulates inputs to a Default call.

type LogProvider

type LogProvider interface {
	Debug(ctx context.Context, msg string, args ...any)
	Info(ctx context.Context, msg string, args ...any)
	Warning(ctx context.Context, msg string, args ...any)
	Error(ctx context.Context, err error)
	Critical(ctx context.Context, err error)
}

LogProvider defines how a logger should behave.

Jump to

Keyboard shortcuts

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