---
description: The main function used to create a route branch
---

# route

## 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])
```
