middleware

package
v1.11.12 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultHealthPath = "/healthz"

Variables

This section is empty.

Functions

func NewMaxBody

func NewMaxBody(limit int64) server.Layer

Per-route rather than global: an upload endpoint and a JSON one want different caps.

Types

type Compress

type Compress server.Layer

func NewCompress

func NewCompress() Compress

Encoded lazily during Render through a pooled writer, so a response nobody renders costs nothing.

type Error

type Error server.Layer

func NewErrorRenderer

func NewErrorRenderer(renderers ...Renderer) Error

NewErrorRenderer: first non-nil renderer wins. defaultRender always matches at the end — pass a catch-all last to replace the default.

type Health

type Health server.Layer

func NewHealth

func NewHealth(path string) Health

NewHealth: empty path → DefaultHealthPath.

type Log

type Log server.Layer

func NewLog

func NewLog(logger pry.Logger) Log

NewLog: place outside Error so Log sees the rendered status, not the raw err.

type Recover

type Recover server.Layer

func NewRecover

func NewRecover() Recover

type Renderer

type Renderer func(err error) server.Renderer

Renderer: nil return means "I don't handle this" — chain falls through.

type Session

type Session server.Layer

func NewSession

func NewSession() Session

type Standard

type Standard struct {
	Compress Compress
	Health   Health
	Session  Session
	Tracing  Tracing
	Log      Log
	Error    Error
	Recover  Recover
}

Standard: nil fields are skipped by All().

func NewStandard

func NewStandard(
	c Compress,
	h Health,
	s Session,
	t Tracing,
	l Log,
	e Error,
	r Recover,
) *Standard

func (*Standard) All

func (s *Standard) All() []server.Layer

All returns layers in canonical order (outer → inner):

Compress, Health, Session, Tracing, Log, Error, Recover

Log is outside Error so Log sees the rendered status. Recover is innermost so handler panics are caught. Per-route layers from mux.Get(...) compose inside Recover.

type Tracing

type Tracing server.Layer

func NewTracing

func NewTracing(provider hilton.Provider) Tracing

NewTracing: place after Session (mirrors our span's traceparent into Session so downstream calls inherit it, not the upstream caller's).

Jump to

Keyboard shortcuts

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