VercelEdgeShelf constructor
VercelEdgeShelf({
- FutureOr<
Response> fetch(- Request request
Implementation
VercelEdgeShelf({
this.fetch,
}) {
// Setup the runtime environment.
setupRuntime();
if (fetch != null) {
__dartVercelFetchHandler = allowInterop((interop.Request request) {
return futureToPromise(Future(() async {
final clone = request.clone();
final Map<String, String> headers = {};
js_util.callMethod(request.headers, 'forEach', [
allowInterop((value, key, _) {
headers[key] = value;
})
]);
final shelfRequest = shelf.Request(
clone.method,
Uri.parse(clone.url),
body: clone.body,
headers: headers,
);
final response = await fetch!(shelfRequest);
return Response(
await response.readAsString(),
status: response.statusCode,
headers: Headers(response.headers),
).delegate;
}));
});
}
}