@loopback/docs
Version:
Documentation for LoopBack 4
48 lines (31 loc) • 1.02 kB
Markdown
lang: en
title: 'API docs: rest.restapplication.route_3'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.rest.restapplication.route_3.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/rest](./rest.md) > [RestApplication](./rest.restapplication.md) > [route](./rest.restapplication.route_3.md)
## RestApplication.route() method
Register a new route.
<b>Signature:</b>
```typescript
route(verb: string, path: string, spec: OperationObject, handler: Function): Binding;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| verb | <code>string</code> | |
| path | <code>string</code> | |
| spec | <code>OperationObject</code> | |
| handler | <code>Function</code> | |
<b>Returns:</b>
`Binding`
## Example
```ts
function greet(name: string) {
return `hello ${name}`;
}
app.route('get', '/', operationSpec, greet);
```