import { Context } from "https://deno.land/x/acorn@0.5.1/context.ts";
An object that provides context for the associated request and response. This is passed as the first argument to every route handler.
Properties
The instance of Cookies
that allows reading and setting of
cookies on the request and response.
Any Params
that have been parsed out of the URL requested
based on the URL pattern string provided to the Route
.
Information about the parsed user agent string associated with the
Request
if available.
See: std/http/user_agent#UserAgent for more information.
Methods
A convenience method to deal with decoding a JSON string body. It can be
used with an optional Deserializer
which can do advanced
decoding of the body, or it will attempted to be decoded from the JSON
string.
Attempt to upgrade the request to a web socket, returning the socket and the response to be returned.
Example
import { Router } from "https://deno.land/x/acorn/mod.ts";
const router = new Router();
router.get("/ws", (ctx) => {
const { socket, response } = ctx.upgrade();
// Perform actions with the socket.
return response;
});
router.listen({ port: 8000 });