next method

Middleware next(
  1. Middleware nextMiddleware
)

Chains the current middleware with a nextMiddleware function and returns a new middleware handler that applies the current middleware followed by the nextMiddleware.

This method allows you to create a new middleware handler that chains the behavior of the current middleware and the nextMiddleware, forming a sequence of middleware to process requests in the specified order.

Implementation

Middleware next(Middleware nextMiddleware) {
  Handler middleware(Handler handler) {
    return this(nextMiddleware(handler));
  }

  return middleware;
}