Taxum / @taxum/core / middleware/request-id / SetRequestIdLayer
Class: SetRequestIdLayer
Defined in: middleware/request-id.ts:28
A layer that manages request IDs for incoming requests.
This function ensures that each request is associated with a unique identifier, which can be either provided in the request headers or dynamically generated.
Example
import { SetRequestIdLayer } from "@taxum/core/middleware/request-id";
import { m, Router } from "@taxum/core/routing";
const router = new Router()
.route("/", m.get(() => "Hello World))
.layer(SetRequestIdLayer.default());
Implements
Constructors
Constructor
new SetRequestIdLayer(
headerName?
,makeRequestId?
):SetRequestIdLayer
Defined in: middleware/request-id.ts:38
Creates a new SetRequestIdLayer.
Parameters
headerName?
string
the name of the header to be used.
makeRequestId?
a function to generate a request ID.
Returns
SetRequestIdLayer
Methods
layer()
layer(
inner
):HttpService
Defined in: middleware/request-id.ts:52
Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.
Parameters
inner
Returns
Implementation of
default()
static
default():SetRequestIdLayer
Defined in: middleware/request-id.ts:48
Creates a new middleware with the header name defaulting to X-Request-Id
with UUID request IDs.
Returns
SetRequestIdLayer