Skip to content

Taxum / @taxum/core / middleware/request-id / PropagateRequestIdLayer

Class: PropagateRequestIdLayer

Defined in: middleware/request-id.ts:108

A layer that propagates a request ID header from the incoming request to the outgoing response.

The purpose of this layer is to ensure consistency of the request ID header across the request-response cycle. If the response does not already include the request ID header, it will include the one from the incoming request. Additionally, the request ID is stored in the response extensions for further processing.

Example

ts
import { PropagateRequestId } from "@taxum/core/middleware/request-id";
import { m, Router } from "@taxum/core/routing";

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

Implements

Constructors

Constructor

new PropagateRequestIdLayer(headerName?): PropagateRequestIdLayer

Defined in: middleware/request-id.ts:116

Creates a new PropagateRequestIdLayer.

Parameters

headerName?

string

the name of the header to be used.

Returns

PropagateRequestIdLayer

Methods

layer()

layer(inner): HttpService

Defined in: middleware/request-id.ts:128

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


default()

static default(): PropagateRequestIdLayer

Defined in: middleware/request-id.ts:124

Creates a new middleware with the header name defaulting to X-Request-Id.

Returns

PropagateRequestIdLayer