File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace SBSEDV \Bundle \RequestIdBundle \HttpClient ;
4+
5+ use SBSEDV \Bundle \RequestIdBundle \Provider \RequestIdProviderInterface ;
6+ use Symfony \Component \HttpClient \DecoratorTrait ;
7+ use Symfony \Contracts \HttpClient \HttpClientInterface ;
8+ use Symfony \Contracts \HttpClient \ResponseInterface ;
9+
10+ class RequestIdSettingHttpClient implements HttpClientInterface
11+ {
12+ use DecoratorTrait;
13+
14+ public function __construct (
15+ private HttpClientInterface $ client ,
16+ private RequestIdProviderInterface $ requestIdProvider ,
17+ private string $ headerName = 'x-request-id '
18+ ) {
19+ }
20+
21+ /**
22+ * {@inheritdoc}
23+ */
24+ public function request (string $ method , string $ url , array $ options = []): ResponseInterface
25+ {
26+ @$ options ['headers ' ][$ this ->headerName ] = $ this ->requestIdProvider ->getCurrentRequestId ();
27+
28+ return $ this ->request ($ method , $ url , $ options );
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments