fromShelf function
Adapts a complete Shelf pipeline, preserving its streaming bodies and repeated headers. Shelf owns change(), context, encoding and middleware semantics inside the pipeline. Arbitrary socket hijacking is unsupported.
Implementation
Future<dv.Response> Function(dv.Request) fromShelf(shelf.Handler handler) =>
(request) async {
final response = await handler(shelf.Request(
request.method,
request.url,
headers: request.headers.multiValueMap,
body: request.body.stream,
context: {
if (request.peerAddress != null)
'dartvel.peerAddress': request.peerAddress!,
},
));
return dv.Response(response.statusCode,
headers: dv.Headers(response.headersAll), body: response.read());
};