Skip to content

Taxum / @taxum/core / middleware/client-ip / SetClientIpLayer

Class: SetClientIpLayer

Defined in: middleware/client-ip.ts:29

A layer that extracts the client IP address from the request.

If trustProxy is set to true, the x-forwarded-for header is considered.

The client IP can later be accessed through the CLIENT_IP extension key.

Example

ts
import { SetClientIpLayer } from "@taxum/core/middleware/client-ip";
import { m, Router } from "@taxum/core/routing";

const router = new Router()
    .route("/", m.get(() => "Hello World))
    .layer(new SetClientIpLayer());

Implements

Constructors

Constructor

new SetClientIpLayer(trustProxy): SetClientIpLayer

Defined in: middleware/client-ip.ts:37

Creates a new SetClientIpLayer.

Parameters

trustProxy

boolean = false

whether to trust proxy headers.

Returns

SetClientIpLayer

Methods

layer()

layer(inner): HttpService

Defined in: middleware/client-ip.ts:41

Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.

Parameters

inner

HttpService

Returns

HttpService

Implementation of

Layer.layer