Skip to main content
Module

x/nhttp/index.ts>Router

An Simple Http Route framework for Deno and Friends. So Hot 🚀
Go to Latest
class Router
Re-export
import { Router } from "https://deno.land/x/nhttp@1.1.16/index.ts";

Router

Examples

const router = new Router(); const router = new Router({ base: '/items' });

Constructors

new
Router(unnamed 0?: TRouter)

Properties

private
base: string
c_routes: TObject[]
midds: TRet[]
pmidds: TObject | undefined
route: TObject

Methods

private
findPathAssets(path: string)
any<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method ANY (allow all method directly) (app or router)

connect<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method CONNECT (app or router)

delete<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method DELETE (app or router)

find(
method: string,
path: string,
setParam: (obj: TObject) => void,
notFound: (rev: Rev, next: NextFunction) => TRet,
): Handler<Rev>[]
get<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method GET (app or router)

head<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method HEAD (app or router)

on<T>(
method: string,
path: string | RegExp,
...handlers: Handlers<Rev & T>,
)

build handlers (app or router)

options<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method OPTIONS (app or router)

patch<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method PATCH (app or router)

post<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method POST (app or router)

put<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method PUT (app or router)

trace<T>(path: string | RegExp, ...handlers: Handlers<Rev & T>): this

method TRACE (app or router)

use<T>(prefix: string | RouterOrWare<Rev & T> | RouterOrWare<Rev & T>[], ...routerOrMiddleware: Array<RouterOrWare<Rev & T> | RouterOrWare<Rev & T>[]>)

add middlware or router.