Skip to main content
Module

x/cav/mod.ts>CtxArg

A server framework for Deno
Go to Latest
interface CtxArg
import { type CtxArg } from "https://deno.land/x/cav@0.0.21/mod.ts";

Arguments available to the Ctx function of an Rpc.

Properties

req: Request

The incoming Request.

res: ResponseInit & { headers: Headers; }

A ResponseInit applied to the Rpc response after resolving and packing the value to send to the client. The Headers object is always available. If the resolved value is a Response object already, the status and statusText will be ignored but the headers will still be applied.

url: URL

The WHATWG URL for the current Request.

conn: http.ConnInfo

The Deno-provided ConnInfo associated with the request.

path: string

The path that matched the Rpc's path init option.

query: Record<string, string | string[]>

The raw query object associated with this request.

groups: Record<string, string>

The raw path groups object associated with this request.

cleanup: (fn: () => Promise<void> | void) => void

Some Ctx functions may need to run cleanup tasks once a Response is ready to send back to the client. Functions registered with cleanup() will be added to a stack structure, and just before the Rpc returns a response, the registered tasks will be executed in stack order (Last In First Out).