Module

x/aleph/types.ts>APIRequest

The Full-stack Framework in Deno.
Very Popular
Go to Latest
interface APIRequest
implements ServerRequest
import { type APIRequest } from "https://dotland.deno.dev/x/aleph@v0.3.0-alpha.33/types.ts";

An interface extends the ServerRequest for API requests.

Properties

readonly
params: Record<string, string>
readonly
query: URLSearchParams
readonly
cookies: ReadonlyMap<string, string>
readonly
hostname: string

Methods

readBody(type?: "raw"): Promise<Uint8Array>

readBody reads the body to an object in bytes, string, json, or multipart form data.

readBody(type: "text"): Promise<string>
readBody(type: "json"): Promise<any>
readBody(type: "form"): Promise<MultipartFormData>
addHeader(key: string, value: string): this

addHeader adds a new value onto an existing response header of the request, or adds the header if it does not already exist.

setHeader(key: string, value: string): this

setHeader sets a new value for an existing response header of the request, or adds the header if it does not already exist.

removeHeader(key: string): this

removeHeader removes the value for an existing response header of the request.

status(code: number): this

status sets response status of the request.

send(data?: string | Uint8Array | ArrayBuffer, contentType?: string): Promise<void>

send replies to the request with any content with type.

json(data: any): Promise<void>

json replies to the request with a json content.

redirect(url: string, status?: Status): this

redirect replies to redirect the client to another URL with optional response status defaulting to 302.