getAfterMiddleware<T> function

Middleware<T> getAfterMiddleware<T>(
  1. Middleware<T> middleware,
  2. Middleware<T> afterMiddleware
)

Runs the second middleware after the main

Example:

getAfterMiddleware(
  sendSecureData,
  clearSecurityData
);

Implementation

Middleware<T> getAfterMiddleware<T>(
  Middleware<T> middleware,
  Middleware<T> afterMiddleware,
// ignore: prefer_expression_function_bodies
) {
  return (context, next) async {
    final called = await wrapMiddlewareNextCall(context, middleware);

    if (called) {
      return afterMiddleware(context, next);
    }
  };
}