> For the complete documentation index, see [llms.txt](https://octoris.gitbook.io/octoris/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://octoris.gitbook.io/octoris/router-api/route.md).

# route

The main function used to create a route branch

## Arguments

| Name       | Type  | Description                                                 |
| ---------- | ----- | ----------------------------------------------------------- |
| routePath  | Array | The array of paths for this branch                          |
| methods    | Array | An array of Methods to listen for                           |
| middleware | Array | An array of middleware that should be applied to this route |

{% hint style="warning" %}
If you set middleware at this stage, it will be applied regardless of method
{% endhint %}

## Usage

```javascript
const { router, response, methods } = require('octoris')
const middlewareFn = require('someMiddleware')

function handler (ctx) {
  return response.json(200, ctx.params)
}

router.route(['/', router.param('id')], [methods.GET(handler)])

// Or if you have middleware:
router.route(['/', router.param('id')], [methods.GET(handler)], [middlewareFn])
```
