---
lang: en
title: 'API docs: rest.restapplication.route_1'
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_1.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_1.md)

## RestApplication.route() method

Register a new route invoking a handler function.

**Signature:**

```typescript
route(verb: string, path: string, spec: OperationObject, handler: Function): 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>

handler


</td><td>

Function


</td><td>

The function to invoke with the request parameters described in the spec.


</td></tr>
</tbody></table>
**Returns:**

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

## Example


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


