UNPKG

@loopback/docs

Version:
48 lines (31 loc) 1.23 kB
--- lang: en title: 'API docs: rest.restapplication.route_1' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar 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. <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); ```