Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶
type Middleware[T any] func(T) T
Middleware represents a function that takes an input of type T and returns an output of type T. It is used as a building block for creating middleware chains.
func Chain ¶
func Chain[T any](outer Middleware[T], middlewares ...Middleware[T]) Middleware[T]
Chain creates a new middleware chain by combining the provided middlewares. The outer middleware is the first one to be executed, followed by the rest of the middlewares in the order they are provided. The resulting middleware chain takes an input of type T and returns an output of type T. If no middlewares are provided, the outer middleware is returned as is. Each middleware in the chain is invoked with the output of the previous middleware as its input. The final output of the chain is the result of invoking the outer middleware with the input.