[]previous and next page

Handler

The fetch handler: the single contract every adapter bridges to.

The fetch handler: the single contract every adapter bridges to.

Import#

ts
import type { Handler } from "@shadow-js/dusk/server";

Signature#

ts
interface Handler {
  /** Validated stream limits, present with the streams feature; native adapters configure their payload bounds from them. */
  readonly webSocketLimits?: import("./websocket").WebSocketLimits;
  fetch(request: Request, env?: unknown): Promise<Response>;
  /**
   * Present only when the handler runs its middleware for files (`runMiddlewareForStaticFiles`): decides a request that
   * names a file the server would serve (see {@link AssetDecision}). A server asks it once it has found the file, and
   * sends the file or the answer. Absent otherwise, so a server that does not run middleware for files never calls it.
   */
  gateAsset?(request: Request, platform?: unknown): Promise<AssetDecision>;
  /**
   * Decides a WebSocket upgrade: refuses it with a response, or accepts it with the handshake headers and
   * the start function the transport calls once it has written the 101 response. Present on every handler
   * built by {@link createHandler}; a runtime without upgrades does not call it.
   */
  upgrade?(request: Request, platform?: unknown): Promise<UpgradeDecision>;
}

Members#

Name Type Description
webSocketLimits? readonly webSocketLimits?: import("./websocket").WebSocketLimits Validated stream limits, present with the streams feature; native adapters configure their payload bounds from them.
fetch fetch(request: Request, env?: unknown): Promise<Response>
gateAsset? gateAsset?(request: Request, platform?: unknown): Promise<AssetDecision> Present only when the handler runs its middleware for files (runMiddlewareForStaticFiles): decides a request that names a file the server would serve (see AssetDecision). A server asks it once it has found the file, and sends the file or the answer. Absent otherwise, so a server that does not run middleware for files never calls it.
upgrade? upgrade?(request: Request, platform?: unknown): Promise<UpgradeDecision> Decides a WebSocket upgrade: refuses it with a response, or accepts it with the handshake headers and the start function the transport calls once it has written the 101 response. Present on every handler built by createHandler; a runtime without upgrades does not call it.