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

x/danet/src/deps.ts>Router#use

The most mature backend framework for Deno
Go to Latest
method Router.prototype.use
import { Router } from "https://deno.land/x/danet@1.7.4/src/deps.ts";

Register middleware to be used on every matched route.

Type Parameters

optional
P extends RouteParams<string> = RouteParams<string>
optional
S extends State = RS

Parameters

middleware: RouterMiddleware<string, P, S>
...middlewares: RouterMiddleware<string, P, S>[]

Returns

Router<S extends RS ? S : (S & RS)>

Register middleware to be used on every route that matches the supplied path.

Type Parameters

R extends string
optional
P extends RouteParams<R> = RouteParams<R>
optional
S extends State = RS

Parameters

path: R
middleware: RouterMiddleware<R, P, S>
...middlewares: RouterMiddleware<R, P, S>[]

Returns

Router<S extends RS ? S : (S & RS)>

Register middleware to be used on every route that matches the supplied path with explicit path parameters.

Type Parameters

P extends RouteParams<string>
optional
S extends State = RS

Parameters

path: string
middleware: RouterMiddleware<string, P, S>
...middlewares: RouterMiddleware<string, P, S>[]

Returns

Router<S extends RS ? S : (S & RS)>

Type Parameters

optional
P extends RouteParams<string> = RouteParams<string>
optional
S extends State = RS

Parameters

path: string[]
middleware: RouterMiddleware<string, P, S>
...middlewares: RouterMiddleware<string, P, S>[]

Returns

Router<S extends RS ? S : (S & RS)>