---
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.

**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)<!-- -->&lt;[ControllerInstance](./rest.controllerinstance.md)<!-- -->&gt;


</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();
```


