Cascade constructor

Cascade({
  1. Iterable<int>? statusCodes,
  2. bool shouldCascade(
    1. Response
    )?,
})

A class that supports calling multiple handlers in sequence and returns the first acceptable response.

By default, a response is considered acceptable if it has a status other than 404 or 405; other statuses indicate that the handler understood the request.

If all handlers return unacceptable responses, the final response will be returned.

final handler = Cascade()
  .add(staticAssetHandler)
  .add(router)
  .handler;

Implementation

Cascade({
  Iterable<int>? statusCodes,
  bool Function(Response)? shouldCascade,
}) : this._(
        shelf.Cascade(
          statusCodes: statusCodes,
          shouldCascade: shouldCascade != null
              ? (response) => shouldCascade(Response._(response))
              : null,
        ),
      );