Request ID Middleware
The request ID middleware adds a unique request ID header to each requests so it can be tracked for debugging later on.
To install via Composer, use the command below, it will automatically detect the latest version and bind it with
composer require api-clients/middleware-request-id
This middleware ships with two build in strategies for generating a random ID. Namely
Uuid4Strategy. Both can be use by setting their FQCN as the
use ApiClients\Foundation\Transport\Options as TransportOptions; use ApiClients\Middleware\RequestId\Options as RequestIdMiddlewareOptions; use ApiClients\Middleware\RequestId\RequestIdMiddleware; use ApiClients\Middleware\UserAgent\RequestIdStrategy\RandomBytesStrategy; $transportOptions = [ TransportOptions::MIDDLEWARE => [ RequestIdMiddleware::class, ], TransportOptions::DEFAULT_REQUEST_OPTIONS => [ RequestIdMiddleware::class => [ RequestIdMiddlewareOptions::STRATEGY => RandomBytesStrategy::class, ], ], ],
STRATEGYWhich strategy to use, pass class name must implement
RequestIdStrategyInterfaceor else it will be ignored.
USER_AGENTThe contents of the user agent header to be used with the