Skip to main content
Module

x/cav/mod.ts>RequestContext

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

A metadata cache object generated once for every Request handled with a Cav handler (Stacks and Rpcs).

Properties

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.

url: URL

new URL(req.url)

path: string

The request path. This is intended to be modified by a Stack during request routing. When the RequestContext is initially generated, this is set to the url.pathname. As the request gets processed, the Stack matches this path against registered routes. When a route matches, this path will be set to the unmatched portion of the requested path before calling the matching route handler.

groups: Record<string, string>

As Stacks process a request, they can capture path groups. The path groups are stored in this object. During name conflicts, old groups will be overwritten by groups captured further down the handler tree.

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

An object created from the url.searchParams. This is what gets processed when an Rpc has a "query" parser.

redirect: Response | null

If this property isn't null, it's a redirect Response that should be returned as soon as possible. It means the client requested a non-canonical path that either ends in a trailing slash or contains empty path segments. Cav requires redirects all non-canonical paths to their canonical version.