Page Contents

Home > @loopback/rest > RestApplication > route

RestApplication.route() method

Register a new route.

Signature:

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

Parameters

Parameter Type Description
verb string  
path string  
spec OperationObject  
handler Function  

Returns:

Binding

Example

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