UNPKG

@loopback/docs

Version:

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

46 lines (29 loc) 1.28 kB
--- lang: en title: 'API docs: rest.restserver.controller' 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.controller.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; [controller](./rest.restserver.controller.md) ## RestServer.controller() method Register a controller class with this server. <b>Signature:</b> ```typescript controller(controllerCtor: ControllerClass<ControllerInstance>): Binding; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | controllerCtor | [ControllerClass](./rest.controllerclass.md)<!-- -->&lt;[ControllerInstance](./rest.controllerinstance.md)<!-- -->&gt; | The controller class (constructor function). | <b>Returns:</b> [Binding](./context.binding.md) The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications. ## Example ```ts class MyController { } app.controller(MyController).lock(); ```