UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

76 lines (42 loc) 1.19 kB
--- lang: en title: 'API docs: rest.restserver.route_2' 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.restserver.route_2.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_2.md) ## RestServer.route() method Register a new generic route. **Signature:** ```typescript route(route: RouteEntry): Binding; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> route </td><td markdown="1"> [RouteEntry](./rest.routeentry.md) </td><td markdown="1"> The route to add. </td></tr> </tbody></table> **Returns:** [Binding](./context.binding.md) ## Example ```ts function greet(name: string) { return `hello ${name}`; } const route = new Route('get', '/', operationSpec, greet); app.route(route); ```