Skip to content

Router

Router is the class of the framework that handles routing and middleware registration.

Constructor

This section is empty.

Properties

This section is empty.

Methods

use

Signature:

use(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles requests of any method.

get

Signature:

get(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles GET requests.

Signature:

head(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles HEAD requests.

post

Signature:

post(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles POST requests.

put

Signature:

put(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles PUT requests.

patch

Signature:

patch(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles PATCH requests.

delete

Signature:

delete(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles DELETE requests.

options

Signature:

options(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles OPTIONS requests.

connect

Signature:

connect(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles CONNECT requests.

trace

Signature:

trace(path?: string, handler: RequestHandler | Router): Router

where

  • path: string | undefined — optional request path
  • handler: RequestHandler | Router — handler for the incoming request

Adds middleware that handles TRACE requests.