handle method

Middleware handle()

Returns a Middleware that rejects requests exceeding the size limit.

Implementation

Middleware handle() {
  return (Context ctx, Next next) async {
    final contentLength = ctx.request.rawRequest.contentLength;

    if (contentLength > maxBytes) {
      return Response(statusCode: 413, body: 'Request Entity Too Large');
    }

    return await next();
  };
}