Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/oak/router.ts>Layer

A middleware framework for handling HTTP with Deno, Node, Bun and Cloudflare Workers 🐿️ 🦕
Very Popular
Latest
class Layer
import { Layer } from "https://deno.land/x/oak@v17.1.2/router.ts";

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

Constructors

new
Layer(
path: string,
methods: HTTPMethods[],
middleware: RouterMiddleware<R, P, S> | RouterMiddleware<R, P, S>[],
unnamed 3?: LayerOptions,
)

Type Parameters

R extends string
optional
P extends RouteParams<R> = RouteParams<R>
optional
S extends State = Record<string, any>

Properties

methods: HTTPMethods[]
optional
name: string
path: string
stack: RouterMiddleware<R, P, S>[]

Methods

captures(path: string): string[]
clone(): Layer<R, P, S>
match(path: string): boolean
param(param: string, fn: RouterParamMiddleware<any, any, any>): this
params(captures: string[], existingParams?: RouteParams<R>): RouteParams<R>
setPrefix(prefix: string): this
toJSON(): Route<any, any, any>
url(params?: RouteParams<R>, options?: UrlOptions): string
[Symbol.for("Deno.customInspect")](inspect: (value: unknown) => string): string
[Symbol.for("nodejs.util.inspect.custom")](
depth: number,
options: any,
inspect: (value: unknown, options?: unknown) => string,
): any