https://github.com/jonaskello/shelf_buffer_request
A middleware for shelf that buffers the request so its body can be read multiple times.
https://github.com/jonaskello/shelf_buffer_request
Last synced: 9 months ago
JSON representation
A middleware for shelf that buffers the request so its body can be read multiple times.
- Host: GitHub
- URL: https://github.com/jonaskello/shelf_buffer_request
- Owner: jonaskello
- License: bsd-3-clause
- Created: 2015-04-24T22:50:41.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-26T16:09:14.000Z (about 11 years ago)
- Last Synced: 2024-10-05T02:21:09.773Z (over 1 year ago)
- Language: Dart
- Size: 129 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# shelf_buffer_request
A middleware for shelf that buffers the request so its body can be read multiple times.
## Usage
A simple usage example:
main() {
Handler handler = const Pipeline()
.addMiddleware(logRequests())
.addMiddleware(bufferRequests())
.addMiddleware(readBodyMiddleware)
.addMiddleware(readBodyMiddleware)
.addMiddleware(readBodyMiddleware)
.addHandler((request) => new Response.ok("Got it!"));
io.serve(handler, InternetAddress.ANY_IP_V4, 1234).then((server) {
print('Serving at http://${server.address.host}:${server.port}');
});
}
Handler readBodyMiddleware(Handler innerHandler) {
return (Request request) async {
var body = await request.read().toList();
print("The body size was ${body.length}");
return innerHandler(request);
};
}
## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/jonaskello/shelf_buffer_request/issues