Skip to main content
Module

x/hono/mod.ts>Context

Ultrafast web framework for Cloudflare Workers, Deno, and Bun. Fast, but not only fast.
Extremely Popular
Go to Latest
class Context
import { Context } from "https://deno.land/x/hono@v3.0.0-0/mod.ts";

Constructors

new
Context(req: Request, options?: ContextOptions<E, R>)

Type Parameters

optional
E extends Partial<Environment> = Environment
optional
R extends Route = Route
optional
I = any

Properties

private
_executionCtx: FetchEvent | ExecutionContext | undefined
private
_headers: Record<string, string[]> | undefined
private
_map: Record<string, unknown> | undefined
private
_paramData: Record<string, string> | undefined
private
_pretty: boolean
private
_prettySpace: number
private
optional
_req: HonoRequest<R, I>
private
_res: Response | undefined
private
_status: StatusCode
private
notFoundHandler: NotFoundHandler<E, R>
private
rawRequest: Request
env: E["Bindings"]
error: Error | undefined
readonly
event: FetchEvent
readonly
executionCtx: ExecutionContext
finalized: boolean
readonly
req: HonoRequest<R, I>
readonly
runtime: Runtime

Methods

private
_finalizeHeaders(incomingHeaders: Headers): HeaderField[]
body(
data: Data | null,
status?: StatusCode,
headers?: Headers,
): Response
get<Key extends keyof E["Variables"]>(key: Key): E["Variables"][Key]
get<Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]
get<T>(key: string): T
header(
name: string,
value: string,
options?: { append?: boolean; },
): void
html(
html: string,
status?: StatusCode,
headers?: Headers,
): Response
json<T>(
object: T,
status?: StatusCode,
headers?: Headers,
): Response
jsonT<T>(
object: T,
status?: StatusCode,
headers?: Headers,
): TypeResponse<T>
newResponse(
data: Data | null,
status: StatusCode,
headers?: Headers,
): Response
notFound(): Response | Promise<Response>
pretty(prettyJSON: boolean, space?: number): void
redirect(location: string, status?: StatusCode): Response
set<Key extends keyof ContextVariableMap>(key: Key, value: ContextVariableMap[Key]): void
set<Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]): void
set(key: string, value: unknown): void
status(status: StatusCode): void
text(
text: string,
status?: StatusCode,
headers?: Headers,
): Response