Skip to content

Commit

Permalink
Merge pull request #22 from Clearfacts/CLEARFACTS-10717
Browse files Browse the repository at this point in the history
[CLEARFACTS-10717] use correct header
  • Loading branch information
ctrl-f5 authored Oct 24, 2024
2 parents 38e025b + a65cb8d commit f39467f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Correlation/Http/CorrelationHttpClientDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class CorrelationHttpClientDecorator implements HttpClientInterface
{
use DecoratorTrait;

public const HEADER_CORRELATION_ID = 'X-Correlation-ID';

private Correlation $correlation;

public function __construct(
Expand All @@ -26,8 +28,8 @@ public function __construct(

public function request(string $method, string $url, array $options = []): ResponseInterface
{
if (!isset($options['headers']) || !array_key_exists('correlation_id', $options['headers'])) {
$options['headers']['correlation_id'] = $this->correlation->getId();
if (!isset($options['headers']) || !array_key_exists(self::HEADER_CORRELATION_ID, $options['headers'])) {
$options['headers'][self::HEADER_CORRELATION_ID] = $this->correlation->getId();
}

return $this->client->request($method, $url, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testAddsHeader(): void
Correlation::setId('test-id');

$client = new MockHttpClient(function ($method, $url, $options) {
$this->assertSame(['correlation_id: test-id'], $options['normalized_headers']['correlation_id'] ?? null);
$this->assertSame([CorrelationHttpClientDecorator::HEADER_CORRELATION_ID . ': test-id'], $options['normalized_headers']['x-correlation-id'] ?? null);

return new MockResponse();
});
Expand Down

0 comments on commit f39467f

Please sign in to comment.