Serve constructor
Serve({
- required Future<
Response?> fetch(- Request,
- Server
- WebSocketHandler? websocket,
Creates a new Bun serve.
Implementation
factory Serve({
required Future<web.Response?> Function(web.Request, Server) fetch,
WebSocketHandler? websocket,
}) {
JSPromise<web.Response?> handle(web.Request request, Server server) {
return fetch(request, server).toJS;
}
final inner = JSObject()
..['fetch'] = handle.toJS
..['websocket'] = websocket;
return Serve._(inner);
}