Skip to content

Taxum / @taxum/core / routing / MethodRouter

Class: MethodRouter

Defined in: routing/method-router.ts:60

Represents a router for mapping HTTP methods and their handlers to specific endpoints.

The class supports various HTTP methods and allows defining handlers for GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, TRACE, and CONNECT methods. It also supports a fallback mechanism and the ability to apply middleware layers to all endpoints.

Implements

Methods

connect()

connect(handler): this

Defined in: routing/method-router.ts:208

Registers an HTTP CONNECT request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


delete()

delete(handler): this

Defined in: routing/method-router.ts:217

Registers an HTTP DELETE request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


fallback()

fallback(handler): this

Defined in: routing/method-router.ts:289

Registers a fallback handler which is called if no other method matches.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


get()

get(handler): this

Defined in: routing/method-router.ts:226

Registers an HTTP GET request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


head(handler): this

Defined in: routing/method-router.ts:235

Registers an HTTP HEAD request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


layer()

layer(layer): MethodRouter

Defined in: routing/method-router.ts:299

Applies the specified layer to all endpoint mappings within this router.

Parameters

layer

HttpLayer<HttpResponseLike>

the middleware to be applied to the endpoints.

Returns

MethodRouter


on()

on(filter, handler): this

Defined in: routing/method-router.ts:124

Registers a handler function for specific HTTP methods based on the provided filter.

Parameters

filter

MethodFilter

the filter that determines which methods the handler should be applied to.

handler

Handler

the handler function to be executed for the specified methods and filter.

Returns

this


options()

options(handler): this

Defined in: routing/method-router.ts:244

Registers an HTTP OPTIONS request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


patch()

patch(handler): this

Defined in: routing/method-router.ts:253

Registers an HTTP PATCH request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


post()

post(handler): this

Defined in: routing/method-router.ts:262

Registers an HTTP POST request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


put()

put(handler): this

Defined in: routing/method-router.ts:271

Registers an HTTP PUT request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


trace()

trace(handler): this

Defined in: routing/method-router.ts:280

Registers an HTTP TRACE request handler.

Parameters

handler

Handler

the handler function to be executed for this method.

Returns

this


default()

static default(): MethodRouter

Defined in: routing/method-router.ts:99

Returns

MethodRouter