---
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) &gt; [@loopback/rest](./rest.md) &gt; [RestServer](./rest.restserver.md) &gt; [handler](./rest.restserver.handler.md)

## RestServer.handler() method

Configure a custom sequence function for handling incoming requests.

**Signature:**

```typescript
handler(handlerFn: SequenceFunction): void;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  handlerFn | [SequenceFunction](./rest.sequencefunction.md) | The handler to invoke for each incoming request. |

**Returns:**

void

## Example


```ts
app.handler(({request, response}, sequence) => {
  sequence.send(response, 'hello world');
});
```


