Skip to content

Commit

Permalink
Merge pull request #74 from Jeroen-G/api-creds
Browse files Browse the repository at this point in the history
allow usage of API credentials
  • Loading branch information
Jeroen-G authored Jan 1, 2022
2 parents 7eb7ecf + fa306ab commit dea964e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ExplorerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ public function boot(): void
}

$this->app->bind(ElasticClientFactory::class, function () {
$client = ClientBuilder::create()->setHosts([config('explorer.connection')])->build();
return new ElasticClientFactory($client);
$client = ClientBuilder::create()->setHosts([config('explorer.connection')]);

if(config()->has('explorer.connection.api')) {
$client->setApiKey(
config('explorer.connection.api.id'),
config('explorer.connection.api.key')
);
}

return new ElasticClientFactory($client->build());
});

$this->app->bind(IndexAdapterInterface::class, ElasticIndexAdapter::class);
Expand Down

0 comments on commit dea964e

Please sign in to comment.