mid

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package mid contains the set of middleware functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errors

func Errors(log *zap.SugaredLogger) web.Middleware

Errors handles errors coming out of the call chain. It detects normal application errors which are used to respond to the client in a uniform way. Unexpected errors (status >= 500) are logged.

func Logger

func Logger(log *zap.SugaredLogger) web.Middleware

Logger writes some information about the request to the logs in the format: TraceID : (200) GET /foo -> IP ADDR (latency)

func Panics

func Panics() web.Middleware

Panics recovers from panics and converts the panic to an error so it is reported in Metrics and handled in Errors.

func Respond

func Respond(ctx context.Context, w http.ResponseWriter, data any, statusCode int) error

Respond converts a Go value to JSON and sends it to the client.

Types

This section is empty.

Jump to

Keyboard shortcuts

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