import { Context } from "https://deno.land/x/oak_middleware@v0.1.0/deps.ts";
Constructors
new
Context(app: Application<S>, serverRequest: ServerRequest)Properties
state: S
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" } });
Methods
assert(): asserts condition
condition: any,
errorStatus?: ErrorStatus,
message?: string,
props?: object,
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
.
throw(): never
errorStatus: ErrorStatus,
message?: string,
props?: object,
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.