Skip to content

Commit

Permalink
Add a PSR18 caching HTTP client.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 7, 2021
1 parent ec62de2 commit fee7c06
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Resources/config/services.php
Expand Up @@ -12,6 +12,8 @@
use ChampsLibres\WopiBundle\EventListener\WopiDiscoveryListener;
use ChampsLibres\WopiLib\Discovery\WopiDiscovery;
use ChampsLibres\WopiLib\Discovery\WopiDiscoveryInterface;
use Symfony\Component\HttpClient\CachingHttpClient;
use Symfony\Component\HttpClient\Psr18Client;

return static function (ContainerConfigurator $container) {
$services = $container->services();
Expand Down Expand Up @@ -39,8 +41,26 @@

$services
->set(WopiDiscovery::class)
->arg('$configuration', '%wopi%');
->arg('$configuration', '%wopi%')
->arg('$client', service('wopi_bundle.http_client'));

$services
->alias(WopiDiscoveryInterface::class, WopiDiscovery::class);

$services
->set('wopi_bundle.cached_http_client')
->class(CachingHttpClient::class)
->decorate('http_client')
->args([
service('.inner'),
service('http_cache.store'),
]);

$services
->set('wopi_bundle.http_client')
->class(Psr18Client::class)
->decorate('psr18.http_client')
->args([
service('wopi_bundle.cached_http_client')
]);
};

0 comments on commit fee7c06

Please sign in to comment.