import * as acorn from "https://deno.land/x/acorn@0.1.0/mod.ts";
Provides a router which specifically tailored for providing RESTful endpoints.
Example
import { Router } from "https://deno.land/x/acorn/mod.ts";
const router = new Router();
router.get("/", () => ({ hello: "world" }));
const BOOKS = {
"1": { title: "The Hound of the Baskervilles" },
"2": { title: "It" },
};
router.get("/books/:id", (ctx) => BOOKS[ctx.params.id]);
router.listen({ port: 3000 });
Classes
An object that provides context for the associated request and response. This is passed as the first argument to every route handler. | |
A router which is specifically geared for handling RESTful type of requests and providing a straight forward API to respond to them. | |
Error events from the router will be of this type, which provides additional context about the error and provides a way to override the default behaviors of the router. | |
The event class that is emitted when the router starts listening. |
Functions
f auth | A handler which allows easy implementation of authorization for a route. |
Intended to provide an immutable response handler for a route. |
Interfaces
The interface to allow handling of request bodies in a structured way. | |
An abstract interface for a keyring which handles signing of data based on a string based digest. | |
The interface for route handlers, which are provided via a context
argument. The route handler is expected to return a
| |
Options that can be specified when adding a route to the router. | |
An interface of route options which also includes the handler, intended to make it easy to provide a single object to register a route. | |
An interface for handling the responses from a route handler in a structured way. |
Type Aliases
The type alias to help infer what the route parameters are for a route based on the route string. | |
Valid return values from a route handler. | |
Types of data that can be signed cryptographically. | |
Types of keys that can be used to sign data. |