@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
74 lines (40 loc) • 1.22 kB
Markdown
---
lang: en
title: 'API docs: rest.restserver.handler'
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.handler.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/rest](./rest.md) > [RestServer](./rest.restserver.md) > [handler](./rest.restserver.handler.md)
## RestServer.handler() method
Configure a custom sequence function for handling incoming requests.
**Signature:**
```typescript
handler(handlerFn: SequenceFunction): void;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
handlerFn
</td><td markdown="1">
[SequenceFunction](./rest.sequencefunction.md)
</td><td markdown="1">
The handler to invoke for each incoming request.
</td></tr>
</tbody></table>
**Returns:**
void
## Example
```ts
app.handler(({request, response}, sequence) => {
sequence.send(response, 'hello world');
});
```