body: BodyRespond
.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
can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
.error
can get the error object from the middleware if the Handler throws an error.
event: FetchEventLike
executionCtx: ExecutionContext
get: Get<IsAny<E> extends true ? { Variables: ContextVariableMap & Record<string, any>; } : E>
.get()
can use the value specified by the key.
getLayout: () => Layout<PropsForRenderer & { Layout: Layout; }> | undefined
Gets the current layout for the response.
header: SetHeaders
.header()
can set headers.
html: HTMLRespond
json: JSONRespond
.json()
can render JSON as Content-Type:application/json
.
newResponse: NewResponse
redirect: <T extends RedirectStatusCode = 302>() => Response & TypedResponse<undefined, T, "redirect">
.redirect()
can Redirect, default status code is 302.
render: Renderer
.render()
can create a response within a layout.
req: HonoRequest<P, I["out"]>
.req
is the instance of HonoRequest.
.set()
can set the value specified by the key.
setLayout: (layout: Layout<PropsForRenderer & { Layout: Layout; }>) => Layout<PropsForRenderer & { Layout: Layout; }>
Sets the layout for the response.
setRenderer: (renderer: Renderer) => void
.setRenderer()
can set the layout in the custom middleware.
status: (status: StatusCode) => void
text: TextRespond
.text()
can render text as Content-Type:text/plain
.
var: Readonly<ContextVariableMap & (IsAny<E["Variables"]> extends true ? Record<string, any> : E["Variables"])>
.var
can access the value of a variable.