glue

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package glue contains miscellaneous utilities for the OpenAPI bindings layer. This includes functions such as error handling, error mapping and validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPErrorHandler

func HTTPErrorHandler(l *zap.Logger) func(err error, c echo.Context)

HTTPErrorHandler provides an error handler function for use with the Echo router. The purpose of this implementation is to map application level errors to HTTP status codes. This is achieved (currently) with the use of a library called errtag which enables the decoration of error chains with a basic kind of category which helps organise the kind of errors that occur within an app.

func ParameterContext

func ParameterContext(next echo.HandlerFunc) echo.HandlerFunc

ParameterContext is a simple middleware for injecting request metadata into a context object for use with the errctx library. This makes diagnostics easy.

func ValidatorErrorHandler

func ValidatorErrorHandler() func(c echo.Context, err *echo.HTTPError) error

ValidatorErrorHandler is an OpenAPI validator function for structured errors. This is used with `OapiRequestValidatorWithOptions` in order to handle errors that occur at the request validation level before the request reaches the app layer. Validation failures happen due to security schemes not being satisfied or requests not satisfying the specification. The purpose of this function is to process the various types of error that can occur and turn the errors into structured errors which can be serialised properly with `errctx` for logging.

Types

This section is empty.

Jump to

Keyboard shortcuts

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