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

mwchain

package
v1.152.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package mwchain validates an ordered middleware chain against declared ordering dependencies.

A chain is a slice of specs in execution order (outermost first); each spec may name other specs that MUST be outer to it — the canonical case being a middleware that reads a value another writes via context.WithValue, which is invisible unless the writer runs first. Validate rejects any chain in which a required dependency is positioned inner to (or at the same position as) the spec that needs it, so an accidental reorder fails fast instead of silently mis-wiring the chain (issue #758).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(specs []Spec) error

Validate checks that the chain is internally consistent: names are unique, every Requires target exists, and every required middleware is outer to (has a lower index than) the middleware that depends on it. It returns a named error on the first violation so a reorder is caught deterministically.

Types

type Name

type Name string

Name identifies a middleware within a chain.

type Spec

type Spec struct {
	Name     Name
	Requires []Name
	Register func()
}

Spec declares one middleware's identity, the middlewares that must be outer to it (run earlier in execution order), and how to register it.

Jump to

Keyboard shortcuts

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