---
lang: en
title: 'API docs: rest.restserver.route_1'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.rest.restserver.route_1.html
---

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

[Home](./index.md) &gt; [@loopback/rest](./rest.md) &gt; [RestServer](./rest.restserver.md) &gt; [route](./rest.restserver.route_1.md)

## RestServer.route() method

Register a new route invoking a handler function.

<b>Signature:</b>

```typescript
route(verb: string, path: string, spec: OperationObject, handler: Function): Binding;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  verb | <code>string</code> | HTTP verb of the endpoint |
|  path | <code>string</code> | URL path of the endpoint |
|  spec | <code>OperationObject</code> | The OpenAPI spec describing the endpoint (operation) |
|  handler | <code>Function</code> | The function to invoke with the request parameters described in the spec. |

<b>Returns:</b>

`Binding`

## Example


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

```


