serveWasiShelf function

void serveWasiShelf(
  1. Handler createHandler(
    1. ServiceImports imports
    )
)

Registers a shelf.Handler factory as the wasi:http/service@0.3.0 component export.

The createHandler callback receives the world's ServiceImports and is invoked lazily inside wasi:http/handler#handle rather than during the WebAssembly component start function (_start), because the Component Model forbids calling host imports (such as wasi:random/insecure when seeding Dart HashMap / Object.hashCode) during module instantiation.

Implementation

void serveWasiShelf(
  shelf.Handler Function(ServiceImports imports) createHandler,
) {
  serviceComponent((imports) => _ShelfWasiHandler(imports, createHandler));
}