@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
44 lines (28 loc) • 1.05 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.
<b>Signature:</b>
```typescript
handler(handlerFn: SequenceFunction): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| handlerFn | [SequenceFunction](./rest.sequencefunction.md) | The handler to invoke for each incoming request. |
<b>Returns:</b>
void
## Example
```ts
app.handler(({request, response}, sequence) => {
sequence.send(response, 'hello world');
});
```