Skip to main content
Deno 2 is finally here 🎉️
Learn more
Latest
method Router.prototype.use
Re-export
import { Router } from "https://deno.land/x/ptero@3.0/Ptero/deps.ts";

Register middleware to be used on every matched route.

Type Parameters

optional
P extends RouteParams = RP
optional
S extends State = RS

Parameters

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

Returns

Router<P extends RP ? P : (P & RP), S extends RS ? S : (S & RS)>

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

Type Parameters

optional
P extends RouteParams = RP
optional
S extends State = RS

Parameters

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

Returns

Router<P extends RP ? P : (P & RP), S extends RS ? S : (S & RS)>