@loopback/docs
Version:
Documentation for LoopBack 4
46 lines (28 loc) • 1.09 kB
Markdown
lang: en
title: 'API docs: rest.restserver.controller'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
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.
<b>Signature:</b>
```typescript
controller(controllerCtor: ControllerClass<ControllerInstance>): Binding;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| controllerCtor | <code>ControllerClass<ControllerInstance></code> | The controller class (constructor function). |
<b>Returns:</b>
`Binding`
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();
```