Page Contents

Home > @loopback/rest > RestServer > route

RestServer.route() method

Register a new generic route.

Signature:

route(route: RouteEntry): Binding;

Parameters

Parameter Type Description
route RouteEntry The route to add.

Returns:

Binding

Example

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