content_length_validator

Creator: coderz1093

Last updated:

0 purchases

content_length_validator Image
content_length_validator Images

Languages

Categories

Add to Cart

Description:

content length validator

Dart Content Length Validator #
Ensures that your application is not vulnerable to large payload attacks.
Inspired by https://github.com/ericmdantas/express-content-length-validator
Installing #
dart pub add content_length_validator
copied to clipboard
Usage #
As shelf middleware #
import 'package:content_length_validator/content_length_validator.dart';

var handler = const Pipeline()
.addMiddleware(
maxContentLengthValidator(
maxContentLength: YOUR_CONTENT_LENGTH,
),
)
.addMiddleware(logRequests())
.addHandler(_echoRequest);
copied to clipboard
As dart_frog middleware #
import 'package:content_length_validator/content_length_validator.dart';

Handler maxContentLengthValidator(Handler handler) {
return handler.use(fromShelfMiddleware(maxContentLengthValidator(maxContentLength: YOUR_CONTENT_LENGTH,)));
}
copied to clipboard
Defining custom error response #
.addMiddleware(
maxContentLengthValidator(
maxContentLength: YOUR_CONTENT_LENGTH,
errorResponse: Response(
413,
body: 'Your body is too long',
),
),
),
),
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.