x/oak/router.ts

A middleware framework for handling HTTP with Deno, Node, Bun and Cloudflare Workers 🐿️ 🦕
Very Popular
Latest
import * as mod from "https://dotland-vbqsvsrpfncg.deno-staging.dev/x/oak@v17.1.3/router.ts";

Contains the router of oak. Typical usage is the creation of an application instance, the creation of a router instance, registration of route middleware, registration of router with the application, and then starting to listen for requests.

Example

import { Application } from "jsr:@oak/oak@14/application";
import { Router } from "jsr:@oak/oak@14/router";

const app = new Application();
const router = new Router();
router.get("/", (ctx) => {
  ctx.response.body = "hello world!";
});
app.use(router.routes());
app.use(router.allowedMethods());

app.listen();

Classes

An internal class used to group together middleware when using multiple middlewares with a router.

An interface for registering middleware that will run when certain HTTP methods and paths are requested, as well as provides a way to parameterize parts of the requested path.

Interfaces

The internal abstraction of a route used by the oak Router.

Options which can be specified when calling the .allowedMethods() method on a Router instance.

The context passed router middleware.

The interface that Router middleware should adhere to.

Options which can be specified when creating a new instance of a Router.

Middleware that will be called by the router when handling a specific parameter, which the middleware will be called when a request matches the route parameter.

Type Aliases

A dynamic type which attempts to determine the route params based on matching the route string.