* kanban service and stuff
This commit is contained in:
37
src/App/Service/HttpClientFactory.php
Normal file
37
src/App/Service/HttpClientFactory.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\Config\Config;
|
||||
use Zend\Http\Client;
|
||||
|
||||
class HttpClientFactory
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return Client
|
||||
*/
|
||||
public function __invoke(ContainerInterface $container): Client
|
||||
{
|
||||
$configArray = $container->get('config');
|
||||
$config = new Config($configArray['app.config']);
|
||||
|
||||
$httpClient = new Client();
|
||||
$httpClient->setAdapter($curlAdapter = new Client\Adapter\Curl());
|
||||
$curlAdapter->setOptions([
|
||||
'timeout' => 300,
|
||||
]);
|
||||
$curlAdapter
|
||||
->setCurlOption(CURLOPT_SSL_VERIFYPEER, false)
|
||||
->setCurlOption(CURLOPT_SSL_VERIFYHOST, false);
|
||||
if ($config->get('http.proxy.enabled', false)) {
|
||||
$curlAdapter
|
||||
->setCurlOption(CURLOPT_PROXYTYPE, $config->get('http.proxy.type'))
|
||||
->setCurlOption(CURLOPT_PROXY, $config->get('http.proxy.url'));
|
||||
}
|
||||
return $httpClient;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user