* http client service factory moved to its own class, as closure breaks config agregator

This commit is contained in:
Dávid Danyi 2017-09-15 14:55:01 +02:00
parent c40e39c4ad
commit 5047caab1a
3 changed files with 46 additions and 23 deletions

View File

@ -8,4 +8,16 @@
*/
return [
'app.config' => [
'jira.user' => '',
'jira.password' => '',
'jira.query.filtered' => 'https://jirapducc.mo.ca.am.ericsson.se/rest/api/2/search?maxResults=1000&jql=filter=%s&fields=created,resolutiondate',
'jira.query.defaultOpen' => 'https://jirapducc.mo.ca.am.ericsson.se/rest/api/2/search?maxResults=1000&jql=project = TSPCORE AND (type = "JIRA case" OR reporter in (ethfoa, edvipin, ethibi, eistkde, ejzsfek, elszhal, eptezel, ETHRGC, ETHTHS, eszigre, etibrkc, ezsubar)) AND status != Done ORDER BY created DESC&fields=created,resolutiondate',
'jira.query.default' => 'https://jirapducc.mo.ca.am.ericsson.se/rest/api/2/search?maxResults=1000&jql=project = TSPCORE AND (type = "JIRA case" OR reporter in (ethfoa, edvipin, ethibi, eistkde, ejzsfek, elszhal, eptezel, ETHRGC, ETHTHS, eszigre, etibrkc, ezsubar)) ORDER BY created DESC&fields=created,resolutiondate',
'jira.query.legacy' => 'https://jirapducc.mo.ca.am.ericsson.se/rest/api/2/search?jql=project = TSPCORE AND type = "JIRA case" ORDER BY created DESC&maxResults=1000&fields=created,resolutiondate',
'http.proxy.enabled' => false,
'http.proxy.type' => CURLPROXY_SOCKS5,
'http.proxy.url' => "localhost:1080",
],
];

View File

@ -1,8 +1,6 @@
<?php
namespace App;
use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
/**
@ -44,27 +42,7 @@ class ConfigProvider
Action\DbgAction::class => Action\DbgFactory::class,
Service\JiraCollectorService::class => Service\JiraCollectorServiceFactory::class,
Client::class => function(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;
},
Client::class => Service\HttpClientServiceFactory::class,
],
];
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Service;
use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
class HttpClientServiceFactory
{
public function __invoke(ContainerInterface $container)
{
$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;
}
}