当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::getResource方法代码示例

本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getResource方法的具体用法?PHP RequestInterface::getResource怎么用?PHP RequestInterface::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Message\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getResource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: format

 /**
  * @inheritDoc
  */
 public function format(RequestInterface $request, ResponseInterface $response = null, \Exception $error = null, array $customData = [])
 {
     if (in_array($request->getPath(), $this->paths)) {
         $customData = array_merge(['url' => $this->mask((string) $request->getUrl()), 'resource' => $this->mask($request->getResource()), 'request' => $this->mask((string) $request), 'response' => $this->mask((string) $response), 'res_body' => $response ? $this->mask((string) $response) : 'NULL', 'req_body' => $this->mask((string) $request->getBody())], $customData);
     }
     return parent::format($request, $response, $error, $customData);
 }
开发者ID:onlinetravelgroup,项目名称:ean-client,代码行数:10,代码来源:Formatter.php

示例2: getRequestAndQuery

 /**
  * @param RequestInterface $request
  * @return array ['query' => ..., 'request' => ...]
  */
 protected function getRequestAndQuery(RequestInterface $request)
 {
     $query = [];
     foreach ($request->getQuery() as $param => $val) {
         $query[$param] = $val;
     }
     $requestInfo = ['url' => $request->getUrl(), 'path' => $request->getPath(), 'queryString' => (string) $request->getQuery(), 'method' => $request->getMethod(), 'hostname' => $request->getHost(), 'port' => $request->getPort(), 'resource' => $request->getResource()];
     return ['query' => $query, 'request' => $requestInfo];
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:13,代码来源:AbstractSignature.php

示例3: format

 /**
  * Returns a formatted message
  *
  * @param RequestInterface  $request    Request that was sent
  * @param ResponseInterface $response   Response that was received
  * @param \Exception        $error      Exception that was received
  * @param array             $customData Associative array of custom template data
  *
  * @return string
  */
 public function format(RequestInterface $request, ResponseInterface $response = null, \Exception $error = null, array $customData = array())
 {
     $cache = $customData;
     $that = $this;
     return preg_replace_callback('/{\\s*([A-Za-z_\\-\\.0-9]+)\\s*}/', function (array $matches) use($request, $response, $error, &$cache, $that) {
         if (isset($cache[$matches[1]])) {
             return $cache[$matches[1]];
         }
         $result = '';
         switch ($matches[1]) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'req_headers':
                 $result = trim($request->getMethod() . ' ' . $request->getResource()) . ' HTTP/' . $request->getProtocolVersion() . "\r\n" . $that->headers($request);
                 break;
             case 'res_headers':
                 $result = $response ? sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()) . "\r\n" . $that->headers($response) : 'NULL';
                 break;
             case 'req_body':
                 $result = $request->getBody();
                 break;
             case 'res_body':
                 $result = $response ? $response->getBody() : 'NULL';
                 break;
             case 'ts':
                 $result = gmdate('c');
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'req_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'res_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
             default:
                 // handle prefixed dynamic headers
                 if (strpos($matches[1], 'req_header_') === 0) {
                     $result = $request->getHeader(substr($matches[1], 11));
                 } elseif (strpos($matches[1], 'res_header_') === 0) {
                     $result = $response ? $response->getHeader(substr($matches[1], 11)) : 'NULL';
                 }
         }
         $cache[$matches[1]] = $result;
         return $result;
     }, $this->template);
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:83,代码来源:Formatter.php

示例4: getParameters

 /**
  * Get context fields to add to the time-line entry.
  *
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  * @param Exception         $error
  *
  * @return array
  */
 protected function getParameters(RequestInterface $request, ResponseInterface $response = null, Exception $error = null)
 {
     $params = [];
     $keys = array_intersect($this->context, $this->availableParameters);
     foreach ($keys as $key) {
         switch ($key) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'request_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'response_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'status_code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
         }
         $params[$key] = (string) $result ?: '';
     }
     return $params;
 }
开发者ID:jezzdk,项目名称:guzzle-debugbar,代码行数:56,代码来源:DebugbarSubscriber.php


注:本文中的GuzzleHttp\Message\RequestInterface::getResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。