Skip to main content
Module

x/hono/request.ts>HonoRequest

Fast, Lightweight, Web-standards
Extremely Popular
Go to Latest
class HonoRequest
import { HonoRequest } from "https://deno.land/x/hono@v4.2.5/request.ts";

Constructors

new
HonoRequest(
request: Request,
path?: string,
matchResult?: Result<[unknown, RouterRoute]>,
)

Type Parameters

optional
P extends string = "/"
optional
I extends Input["out"] = { }

Properties

private
cachedBody: (key: keyof Body) => unknown
bodyCache: BodyCache
readonly
matchedRoutes: RouterRoute[]

.matchedRoutes() can return a matched route in the handler

readonly
method

.method() can get the method name of the request.

path: string

.path can get the pathname of the request.

raw: Request

.raw can get the raw Request object.

routeIndex: number
readonly
routePath: string

routePath() can retrieve the path registered within the handler

readonly
url

.url() can get the request url strings.

Methods

private
getAllDecodedParams(): Record<string, string>
private
getDecodedParam(key: string): string | undefined
private
getParamValue(paramKey: any): string | undefined
addValidatedData(target: keyof ValidationTargets, data: { })
arrayBuffer(): Promise<ArrayBuffer>

.arrayBuffer() parse Request body as an ArrayBuffer

blob(): Promise<Blob>
formData(): Promise<FormData>
header(name: string): string | undefined

.header() can get the request header value.

header(): Record<string, string>
json<T = any>(): Promise<T>

.json() can parse Request body of type application/json

param<P2 extends string = P>(key: RemoveQuestion<ParamKeys<P2>>): UndefinedIfHavingQuestion<ParamKeys<P2>>

.req.param() gets the path parameters.

param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>
parseBody<T extends BodyData = BodyData>(options?: ParseBodyOptions): Promise<T>

.parseBody() can parse Request body of type multipart/form-data or application/x-www-form-urlencoded

queries(key: string): string[] | undefined

.queries() can get multiple querystring parameter values, e.g. /search?tags=A&tags=B

queries(): Record<string, string[]>
query(key: string): string | undefined

.query() can get querystring parameters.

query(): Record<string, string>
text(): Promise<string>

.text() can parse Request body of type text/plain

valid<T extends keyof I & keyof ValidationTargets>(target: T): InputToDataByTarget<I, T>