echox

package
v2.8.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLoggerConfig = middleware.RequestLoggerConfig{
	LogMethod:     true,
	LogURIPath:    true,
	LogStatus:     true,
	LogLatency:    true,
	HandleError:   true,
	LogValuesFunc: DefaultLogValuesFunc,
}
View Source
var Validator = makeValidator()

Validator implements echo.Validator and can be set as validator in echo. It is probably better to use BindAndValidate though.

Functions

func BindAndValidate

func BindAndValidate[T any](c *echo.Context) (T, error)

BindAndValidate binds the request data to a new instance of type T using c.Bind and then validates the struct using Validator.

func DefaultLogValuesFunc

func DefaultLogValuesFunc(c *echo.Context, v middleware.RequestLoggerValues) error

func ErrorHandler

func ErrorHandler(mapper ErrorMapper) echo.HTTPErrorHandler

ErrorHandler returns an echo error handler. It applies the mapper to the error first and falls back to the default error mapping rules if the mapper returns false or is not defined. Errors are always logged, and if the response has already been committed it can only log, not write a body.

func Logging

func Logging() echo.MiddlewareFunc

Logging returns the default logging middleware. If you dont want that, you can use the DefaultLoggerConfig and DefaultLogValuesFunc to build your own logging middleware

Types

type ErrorMapper

type ErrorMapper func(err error) (api.ErrorResponse, bool)

ErrorMapper translates an arbitrary error into an ErrorResponse. It returns false to signal that it does not handle the given error, in which case the default mapping rules are applied.

Jump to

Keyboard shortcuts

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