Skip to main content
Module

x/cav/mod.ts>ResolveArg

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

Arguments available to a Resolver function.

Type Parameters

Groups extends AnyParser | null
Context extends AnyCtx | null
Query extends AnyParser | null
Message extends AnyParser | null
Upgrade extends boolean | null

Properties

req: Request

The incoming Request this Rpc is handling.

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 this request.

conn: http.ConnInfo

Connection information provided by Deno.

path: string

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

The parsed path groups object captured while routing the request.

ctx: Context extends Ctx<infer C> ? C : undefined

The context created by this Rpc's Ctx function.

The parsed query string parameters object.

message: Upgrade extends true ? undefined : ParserOutput<Message>

If this isn't a socket-type Rpc, this will be the parsed request body.

asset: (opt: ServeAssetOptions) => Promise<Response>

Searches for an asset on disk and either returns a Response containing that asset or throws a 404 HttpError if the asset isn't found. See the documentation for the top-level asset() function for more details; this function is the same thing but bound to the Request received by the Rpc.

redirect: (to: string, status?: number) => Response

Returns a redirect Response. If the redirect path doesn't specify an origin, the origin of the current request is used. If the path starts with a ".", it is joined with the pathname of the request to get the final redirect path. If the status isn't provided, 302 is used.

upgrade: Upgrade extends true ? <Send = unknown>() => Socket<Send, (Message extends AnyParser ? ParserOutput<Message> : unknown)> : undefined

Upgrades the request to become a web socket. This is only available if the upgrade init option is true. The Response returned by this function should be returned by the Rpc's resolve function.