Beispiel #1
0
 public function request($api, $options = array())
 {
     $response = null;
     if (!isset($this->api_list[$api])) {
         return $response;
     }
     list($method, $uri, $default_options) = $this->api_list[$api];
     if (is_null($default_options)) {
         $default_options = array();
     }
     $request_option = $this->get_common_config();
     $request_option = $this->merge_option($request_option, $default_options);
     $request_option = $this->merge_option($request_option, $options);
     $clock = new Clock();
     try {
         $response = $this->client->request($method, $uri, $request_option);
     } catch (TransferException $e) {
         $response = $e->getResponse();
     }
     $time = $clock->spent();
     $log_id = LOG_ID;
     $res = $this->log_response($response);
     $this->logger->info("get response: LOG_ID({$log_id}) time({$time}) res({$res})");
     return $response;
 }
Beispiel #2
0
 public function __invoke($request, $response, $next)
 {
     $log_id = LOG_ID;
     $req = json_encode($this->logRequest($request));
     $this->logger->info("beginning receive req: LOG_ID({$log_id}) req({$req})");
     $clock = new Clock();
     $response = $next($request, $response);
     $time = $clock->spent();
     $res = (string) $response->getBody();
     $this->logger->info("ending send res: LOG_ID({$log_id}) time({$time}) ret({$res})");
     return $response;
 }