You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This middleware provide framework-agnostic possibility to generate and add to request/response header request id.
6
+
7
+
## Installation
8
+
9
+
```json
10
+
{
11
+
"require": {
12
+
"php-middleware/request-id": "^1.0.0"
13
+
}
14
+
}
15
+
```
16
+
17
+
This middleware require in contructor `PhpMiddleware\RequestId\Generator\GeneratorInterface` implementation.
18
+
19
+
```php
20
+
$requestIdMiddleware = new PhpMiddleware\LogHttpMessages\RequestIdMiddleware($generator);
21
+
22
+
$app = new MiddlewareRunner();
23
+
$app->add($requestIdMiddleware);
24
+
$app->run($request, $response);
25
+
```
26
+
27
+
All middleware constructor options:
28
+
29
+
*`PhpMiddleware\RequestId\Generator\GeneratorInterface``$generator` - generator implementation with method `generateRequestId`
30
+
*`bool``$allowOverride` (default `true`) - if `true` and request id header exists in incoming request, then value from request header will be used in middleware, generator will be avoid
31
+
*`bool``$emmitToResponse` (default `true`) - if `true` request id will be added to response header
32
+
*`string``$headerName` (default `X-Request-Id`) - header name
0 commit comments