---
lang: en
title: 'API docs: rest.restapplication.route'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/rest
permalink: /doc/en/lb4/apidocs.rest.restapplication.route.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [RestApplication](./rest.restapplication.md) &gt; [route](./rest.restapplication.route.md)

## RestApplication.route() method

Register a new Controller-based route.

**Signature:**

```typescript
route<T extends object>(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass<T>, controllerFactory: ControllerFactory<T>, methodName: string): Binding;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

verb


</td><td>

string


</td><td>

HTTP verb of the endpoint


</td></tr>
<tr><td>

path


</td><td>

string


</td><td>

URL path of the endpoint


</td></tr>
<tr><td>

spec


</td><td>

OperationObject


</td><td>

The OpenAPI spec describing the endpoint (operation)


</td></tr>
<tr><td>

controllerCtor


</td><td>

[ControllerClass](./rest.controllerclass.md)<!-- -->&lt;T&gt;


</td><td>

Controller constructor


</td></tr>
<tr><td>

controllerFactory


</td><td>

[ControllerFactory](./rest.controllerfactory.md)<!-- -->&lt;T&gt;


</td><td>

A factory function to create controller instance


</td></tr>
<tr><td>

methodName


</td><td>

string


</td><td>

The name of the controller method


</td></tr>
</tbody></table>

**Returns:**

[Binding](./context.binding.md)

## Example


```ts
class MyController {
  greet(name: string) {
    return `hello ${name}`;
  }
}
app.route('get', '/greet', operationSpec, MyController, 'greet');
```


