@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
46 lines (29 loc) • 1.28 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.
<b>Signature:</b>
```typescript
controller(controllerCtor: ControllerClass<ControllerInstance>): Binding;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| controllerCtor | [ControllerClass](./rest.controllerclass.md)<!-- --><[ControllerInstance](./rest.controllerinstance.md)<!-- -->> | 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();
```