diff --git a/src/Client.php b/src/Client.php index dffa598a..4dade36c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -50,9 +50,10 @@ public function __construct( ?ClientInterface $httpClient = null, ?RequestFactoryInterface $requestFactory = null, array $clientAgents = [], - ?StreamFactoryInterface $streamFactory = null + ?StreamFactoryInterface $streamFactory = null, + $headers = [] ) { - $this->http = new MeilisearchClientAdapter($url, $apiKey, $httpClient, $requestFactory, $clientAgents, $streamFactory); + $this->http = new MeilisearchClientAdapter($url, $apiKey, $httpClient, $requestFactory, $clientAgents, $streamFactory, $headers); $this->index = new Indexes($this->http); $this->health = new Health($this->http); $this->version = new Version($this->http); diff --git a/src/Http/Client.php b/src/Http/Client.php index 9eef6472..3ea5f0a9 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -47,7 +47,8 @@ public function __construct( ?ClientInterface $httpClient = null, ?RequestFactoryInterface $reqFactory = null, array $clientAgents = [], - ?StreamFactoryInterface $streamFactory = null + ?StreamFactoryInterface $streamFactory = null, + $headers = [] ) { $this->baseUrl = $url; $this->http = $httpClient ?? Psr18ClientDiscovery::find(); @@ -59,6 +60,7 @@ public function __construct( if (null !== $apiKey && '' !== $apiKey) { $this->headers['Authorization'] = \sprintf('Bearer %s', $apiKey); } + $this->headers = array_merge($this->headers, $headers); $this->json = new Json(); }