import { Context } from "https://dotland.deno.dev/x/hono@v4.2.6/context.ts";
Constructors
new
Context(req: HonoRequest<P, I["out"]>, options?: ContextOptions<E>)Properties
private
_var: E["Variables"]private
layout: Layout<PropsForRenderer & { Layout: Layout; }> | undefinedprivate
notFoundHandler: NotFoundHandler<E>private
renderer: Renderer.body()
can return the HTTP response.
You can set headers with .header()
and set HTTP status code with .status
.
This can also be set in .text()
, .json()
and so on.
env: E["Bindings"]
.env
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
readonly
event: FetchEventLikereadonly
executionCtx: ExecutionContextredirect: (location: string, status?: RedirectStatusCode) => Response
.redirect()
can Redirect, default status code is 302.
setLayout: (layout: Layout<PropsForRenderer & { Layout: Layout; }>) => unknown
setRenderer: (renderer: Renderer) => unknown
.setRenderer()
can set the layout in the custom middleware.
status: (status: StatusCode) => void
readonly
var: Readonly<ContextVariableMap & (IsAny<E["Variables"]> extends true ? Record<string, any> : E["Variables"])>.var
can access the value of a variable.