middleware

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyCleanup = func() {}
View Source
var EmptyMiddleware = func(tripper http.RoundTripper) http.RoundTripper { return tripper }
View Source
var ErrNotFound = errors.New("Middleware has not been registered")

ErrNotFound is middleware not found.

Functions

func Register

func Register(name string, factory Factory)

Register registers one middleware.

Types

type Factory

type Factory func(*configv1.Middleware) (middleware Middleware, cleanup func(), err error)

Factory is a middleware factory.

type Middleware

type Middleware func(http.RoundTripper) http.RoundTripper

Middleware is handler middleware.

func Chain

func Chain(m ...Middleware) Middleware

Chain returns a Middleware that specifies the chained handler for endpoint.

func Create

func Create(c *configv1.Middleware) (Middleware, func(), error)

Create instantiates a middleware based on `cfg`.

type Registry

type Registry interface {
	Register(name string, factory Factory)
	Create(c *configv1.Middleware) (Middleware, func(), error)
}

func NewRegistry

func NewRegistry() Registry

NewRegistry returns a new middleware registry.

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

RoundTripperFunc is an adapter to allow the use of ordinary functions as HTTP RoundTripper.

func (RoundTripperFunc) RoundTrip

func (f RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip calls f(w, r).

Directories

Path Synopsis
countingWriter counts how many bytes have been written to it.
countingWriter counts how many bytes have been written to it.

Jump to

Keyboard shortcuts

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