[**flummpress**](../README.md)

***

[flummpress](../README.md) / Router

# Class: Router

Defined in: router.ts:7

## Constructors

### new Router()

> **new Router**(): `Router`

Defined in: router.ts:12

#### Returns

`Router`

## Methods

### delete()

> **delete**(`path`, ...`callback`): `this`

Defined in: router.ts:158

Registers a route for HTTP DELETE requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### get()

> **get**(`path`, ...`callback`): `this`

Defined in: router.ts:114

Registers a route for HTTP GET requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### getRoute()

> **getRoute**(`path`, `method`): `any`

Defined in: router.ts:220

Finds and returns the route matching the given path and method.

#### Parameters

##### path

`string`

The requested path.

##### method

`string`

The HTTP method (e.g., "GET").

#### Returns

`any`

The matching route or undefined.

***

### group()

> **group**(`basePath`, `callback`): `this`

Defined in: router.ts:42

Registers a new route group with common base path and middleware.

#### Parameters

##### basePath

The base path or RegExp.

`string` | `RegExp`

##### callback

(`methods`) => `void`

Callback to define routes within the group.

#### Returns

`this`

The Router instance for chaining.

***

### head()

> **head**(`path`, ...`callback`): `this`

Defined in: router.ts:136

Registers a route for HTTP HEAD requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### importRoutesFromPath()

> **importRoutesFromPath**(`p`, `tpl`): `Promise`\<`Router`\>

Defined in: router.ts:22

Dynamically imports routes from a directory and registers them.

#### Parameters

##### p

`string`

Path to the directory containing route files.

##### tpl

Optional template instance to use with the routes.

`false` | [`Tpl`](Tpl.md)

#### Returns

`Promise`\<`Router`\>

The Router instance for chaining.

***

### patch()

> **patch**(`path`, ...`callback`): `this`

Defined in: router.ts:169

Registers a route for HTTP PATCH requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### post()

> **post**(`path`, ...`callback`): `this`

Defined in: router.ts:125

Registers a route for HTTP POST requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### put()

> **put**(`path`, ...`callback`): `this`

Defined in: router.ts:147

Registers a route for HTTP PUT requests.

#### Parameters

##### path

The URL path or pattern for the route.

`string` | `RegExp`

##### callback

...`Handler`[]

An array of middleware or handler functions to execute for this route.

#### Returns

`this`

The current instance for method chaining.

***

### static()

> **static**(`options`): `this`

Defined in: router.ts:270

Serves static files from a specified directory.

#### Parameters

##### options

Options for serving static files.

###### dir?

`string` = `...`

Directory containing the static files.

###### route?

`RegExp` = `...`

Regular expression to match the route for static files.

#### Returns

`this`

The Router instance for chaining.

***

### use()

> **use**(`obj`): `void`

Defined in: router.ts:96

Merges routes or assigns a template instance to the Router.

#### Parameters

##### obj

An instance of Router or Tpl.

[`Tpl`](Tpl.md) | `Router`

#### Returns

`void`