Skip to main content
Module

x/deno_koa/context.ts>Context

A middleware framework for Deno's http serve🦕. Transplanted from Koa with ❤️
Latest
class Context
import { Context } from "https://deno.land/x/deno_koa@v1.0.4/context.ts";

Constructors

new
Context(
app: App,
request: Request,
response: Response,
)

Index Signatures

[key: string]: any

Properties

app: App
cookies: Cookies
path: string
request: Request
response: Response

Methods

assert(
value: any,
status: number,
message?: string,
props?: object,
)

Assert condition,creates an HTTP error while provide http status

inspect() implementation, which just returns the JSON output.

onerror(err?: any)
throw(...args: any[]): never

Throw an error with msg and optional status defaulting to 500. Note that these are user-level errors, and the message may be exposed to the client.

this.throw(403) this.throw(400, 'name required') this.throw('something exploded') this.throw(new Error('invalid')) this.throw(400, new Error('invalid'))

Note: status should only be passed as the first parameter.