Middleware

Technical reference of Middleware.


Symbols

SymbolClassDescription
MiddlewaretypeMiddleware defines a public type of API.
UseMiddlewaresfuncRun a chain of middlewares in order.

Middleware

Declaration:

gox
type Middleware[T any] func(ctx *Context, out *T) error

Middleware defines a public type of API.


UseMiddlewares

Declaration:

gox
func UseMiddlewares[T any](ctx *Context, out *T, middlewares ...Middleware[T]) error

Run a chain of middlewares in order.

Parameters

ParameterTypeDescription
ctx*ContextContext of execution.
out*TDestination where the result is decoded.
middlewares...Middleware[T]Type value ...Middleware[T] required by the operation.

Returns

ReturnTypeDescription
errerrornil if the operation ends correctly; otherwise, the error produced.

Behavior

The operation returns an error when it cannot complete the above contract.

Errors

UseMiddlewares returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.

Usage syntax

gox
err := gox.UseMiddlewares(ctx, &value, value)

Next step

Continue with Sessions API.

Sessions