middleware library

Classes

Composer<T extends Object>
A simple middleware compose builder

Functions

BranchMiddlewareCondition<T>(dynamic condition) → void
Check possible types for branch condition
compose<T>(List<Middleware<T>> middlewares) Middleware<T>
getAfterMiddleware<T>(Middleware<T> middleware, Middleware<T> afterMiddleware) Middleware<T>
Runs the second middleware after the main
getBeforeMiddleware<T>(Middleware<T> beforeMiddleware, Middleware<T> middleware) Middleware<T>
Runs the second middleware before the main
getBranchMiddleware<T>(dynamic condition, Middleware<T> trueMiddleware, Middleware<T> falseMiddleware) Middleware<T>
By condition splits the middleware
getCaughtMiddleware<T>(CaughtMiddlewareHandler<T> errorHandler) Middleware<T>
Catches errors in the middleware chain
getConcurrencyMiddleware<T>(List<Middleware<T>> middlewares) Middleware<T>
Concurrently launches middleware, the chain will continue if next() is called in all middlewares.
getEnforceMiddleware<T>(Middleware<T> beforeMiddleware, Middleware<T> middleware, Middleware<T> afterMiddleware) Middleware<T>
Runs middleware before and after the main
getFilterMiddleware<T>(dynamic condition, Middleware<T> filterMiddleware) Middleware<T>
Conditionally runs middleware or stops the chain
getForkMiddleware<T>(Middleware<T> middleware) Middleware<T>
Runs the middleware at the next event loop and force call next()
getLazyMiddleware<T>(LazyMiddlewareFactory<T> middlewareFactory) Middleware<T>
Lazily asynchronously gets middleware
getOptionalMiddleware<T>(dynamic condition, Middleware<T> optionalMiddleware) Middleware<T>
Conditionally runs optional middleware or skips middleware
getTapMiddleware<T>(Middleware<T> middleware) Middleware<T>
Runs the middleware and force call next()
noopNext() Future<void>
Noop for call next() in middleware
skipMiddleware<T>(T context, FutureOr<void> next()) Future
Call next() in middleware
stopMiddleware<T>(T context, FutureOr<void> next()) Future<void>
Does not call next() in middleware

Typedefs

BranchMiddlewareConditionFunction<T> = FutureOr<bool> Function(T context)
Asynchronous function for branch condition
CaughtMiddlewareHandler<T> = dynamic Function(T context, Exception error)
Handler for catching errors in middleware chains
LazyMiddlewareFactory<T> = FutureOr<Middleware<T>> Function(T context)
Asynchronous factory to create middleware
Middleware<T> = dynamic Function(T context, NextMiddleware next)
Basic middleware
NextMiddleware = Future Function()
Call the next middleware from the chain