Web services

WingBlade.web.serve

Use

Start a web server with a handler function.

Syntax

WebServer: WingBlade.web.serve(AsyncFunction<Response>: handler, ?ServeInit: opt = {});

Read ServeInit@std/http/server for more details.

handler

let handler = async function (Request: request, ConnInfo: connInfo) {
	return new Response();
};

WingBlade.web.acceptWs

Use

Upgrade the incoming request to a WebSocket connection.

Syntax

UpgradedWebSocket: WingBlade.web.acceptWs(Request: req, UpgradeWebSocketOptions: opt);

UpgradedWebSocket

{
	response: Response, // The upgrade response for the client
	socket: WebSocketServer // Server-side WebSocket
}

UpgradeWebSocketOptions

{
	protocol: String,
	idleTimeout: Number
}

Read Deno.UpgradeWebSocketOptions for details.

WingBlade.web.acceptSSE

Use

Upgrade the incoming request to a Server-sent Event (EventSink) connection.

Syntax

UpgradedSSE: WingBlade.web.acceptSSE(Request: req);

UpgradedSSE

{
	response: Response, // The upgrade response to the client
	socket: EventSink // Server-side EventSource
}