@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
76 lines (41 loc) • 1.45 kB
Markdown
---
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) > [@loopback/rest](./rest.md) > [RestServer](./rest.restserver.md) > [controller](./rest.restserver.controller.md)
## RestServer.controller() method
Register a controller class with this server.
**Signature:**
```typescript
controller(controllerCtor: ControllerClass<ControllerInstance>): Binding;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
controllerCtor
</td><td markdown="1">
[ControllerClass](./rest.controllerclass.md)<!-- --><[ControllerInstance](./rest.controllerinstance.md)<!-- -->>
</td><td markdown="1">
The controller class (constructor function).
</td></tr>
</tbody></table>
**Returns:**
[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();
```