getBeforeMiddleware<T> function

Middleware<T> getBeforeMiddleware<T>(
  1. Middleware<T> beforeMiddleware,
  2. Middleware<T> middleware
)

Runs the second middleware before the main

Example:

getBeforeMiddleware(
  myMockMiddleware,
  ouputUserData
);

Implementation

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

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