Help us shape the future of Go! Take the 2026 Go Developer Survey

mid

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mid holds the errchain error middleware shared by the JSON APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errors

func Errors(log zerolog.Logger, mappers ...Mapper) errchain.ErrorHandler

Errors turns handler errors into responses: unreadable body 400, validation failure 422, then mappers, then an opaque logged 500.

func Logger

func Logger(l zerolog.Logger, skip ...string) func(http.Handler) http.Handler

Logger logs one line per completed request. Requests to a skip path only log on a non-2xx status, so a poll loop does not flood the log.

Types

type Mapper

type Mapper func(err error) (status int, body any, ok bool)

Mapper translates one API's own error types to a response; the first mapper to report ok wins.

Jump to

Keyboard shortcuts

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