# RouterMethodFactory

**Kind:** Class

**Source:** [`packages/core/helpers/router-method-factory.ts`](https://github.com/nestjs/nest/blob/master/packages/core/helpers/router-method-factory.ts#L23)

**Part of:** [Core](subsystem-packages-core)

`RouterMethodFactory` resolves an HTTP request method into the corresponding routing function on an HTTP server or router instance. It centralizes method lookup and falls back to the router's `use()` handler when a specific HTTP verb is unavailable.

## Methods

| Method | Signature | Returns |
|---|---|---|
| `get` | `get(target: HttpServer, requestMethod: RequestMethod)` | `Function` |

## Where it refuses work

- `RouterMethodFactory` stops the work with an early return when `!method`.

## Diagram

```mermaid
graph LR
  A[RequestMethod] --> B[RouterMethodFactory.get]
  B --> C[REQUEST_METHOD_MAP]
  C --> D{Router supports method?}
  D -->|Yes| E[Return verb handler<br/>get/post/put/etc.]
  D -->|No| F[Return use() fallback]
  E --> G[Register route handler]
  F --> G
```

## Usage

```ts
import { RequestMethod } from '@nestjs/common';
import { RouterMethodFactory } from '@nestjs/core/helpers/router-method-factory';

const methodFactory = new RouterMethodFactory();
const router = app.getHttpAdapter().getInstance();

const registerGet = methodFactory.get(router, RequestMethod.GET);

registerGet.call(router, '/health', (req, res) => {
  res.status(200).json({ status: 'ok' });
});
```

## AI Coding Instructions

- Pass a router or HTTP server object that exposes verb methods such as `get`, `post`, `put`, and `delete`.
- Use `RequestMethod` enum values rather than hard-coded method-name strings.
- Preserve the router receiver when invoking an extracted route method if the underlying adapter depends on `this` (for example, use `.call(router, ...)`).
- Account for the `use()` fallback when integrating adapters that do not implement every HTTP verb.
- Keep HTTP-method-to-router-method mapping changes aligned with the framework's supported `RequestMethod` values.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `ExpressAdapter` — `packages/platform-express/adapters/express-adapter.ts`:51
