The context associated when dealing with serve middleware requests on an application.
app: Application<S>
A reference to the current application.
Request remote address. When the application's .proxy
is true, the
X-Forwarded-For
will be used to determine the requesting remote address.
When the application's .proxy
is true
, this will be set to an array of
IPs, ordered from upstream to downstream, based on the value of the header
X-Forwarded-For
. When false
an empty array is returned.
The object to pass state to front-end views. This can be typed by supplying the generic state argument when creating a new app. For example:
const app = new Application<{ foo: string }>();
Or can be contextually inferred based on setting an initial state object:
const app = new Application({ state: { foo: "bar" } });
On each request/response cycle, the context's state is cloned from the
application state. This means changes to the context's .state
will be
dropped when the request drops, but "defaults" can be applied to the
application's state. Changes to the application's state though won't be
reflected until the next request in the context's state.
[Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string): string
assert(condition: unknown,status?: ErrorStatus,message?: string,props?: Record<string, unknown> & Omit<HttpErrorOptions, "status">,): asserts condition
Asserts the condition and if the condition fails, creates an HTTP error
with the provided status (which defaults to 500
). The error status by
default will be set on the .response.status
.
Because of limitation of TypeScript, any assertion type function requires
specific type annotations, so the ServeContext
type should be
used even if it can be inferred from the context.
Create and throw an HTTP Error, which can be used to pass status
information which can be caught by other middleware to send more
meaningful error messages back to the client. The passed error status will
be set on the .response.status
by default as well.