# HttpProtect.textMiddleware() method · @imqueue/http-protect

Source: https://imqueue.org/api/http-protect/latest/http-protect.httpprotect.textmiddleware/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/http-protect 3.0.1 — generated reference, not hand-written

A middleware that rejects with `text/plain`.

**Signature:**

```typescript
textMiddleware(): (req: Request, res: Response, next: NextFunction) => Promise<void>;
```
**Returns:**

(req: Request, res: [Response](https://imqueue.org/api/http-protect/latest/http-protect.response/), next: [NextFunction](https://imqueue.org/api/http-protect/latest/http-protect.nextfunction/)) => Promise<void>

An async middleware to hand to `app.use()`.

## Remarks

Sends the code and its reason phrase — `429 Too Many Requests`, or `418 I'm a teapot` for a ban. Sets `Content-Type` through [Response.header()](https://imqueue.org/api/http-protect/latest/http-protect.response.header/) if the framework has it, [Response.setHeader()](https://imqueue.org/api/http-protect/latest/http-protect.response.setheader/) otherwise, and omits it if neither exists.

