本文整理汇总了PHP中Slim\Http\Request::getHeaderLine方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getHeaderLine方法的具体用法?PHP Request::getHeaderLine怎么用?PHP Request::getHeaderLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Http\Request
的用法示例。
在下文中一共展示了Request::getHeaderLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTokenId
/**
*
*/
public static function getTokenId(\Slim\Http\Request $req)
{
$auth = $req->getHeaderLine('Authorization');
$hasBearer = preg_match('|Bearer (.+)|', $auth, $m);
if (!$hasBearer) {
return false;
}
$tokenId = $m[1];
return $tokenId;
}
示例2: __invoke
/**
* Invoke handler.
*
* @param Request $request The most recent Request object
* @param Response $response The most recent Response object
*
* @return Response
*/
public function __invoke(Request $request, Response $response)
{
$code = 404;
$template = $this->settings['view']['status'][$code] ?? null;
$isHtml = stripos($request->getHeaderLine('Accept'), 'html') !== false;
if ($template && $isHtml) {
$response = $this->renderTemplate($request, $response, $template, $code);
} else {
$handler = $this->container['defaultNotFoundHandler'];
$response = $handler($request, $response);
}
return $response;
}
示例3: __invoke
/**
* Invoke handler.
*
* @param Request $request The most recent Request object
* @param Response $response The most recent Response object
* @param Throwable $e The caught Exception object
*
* @return \Psr\Http\Message\ResponseInterface|Response
*/
public function __invoke(Request $request, Response $response, Throwable $e)
{
$this->logError($e);
$code = 500;
$template = $this->settings['view']['status'][$code] ?? null;
$isHtml = stripos($request->getHeaderLine('Accept'), 'html') !== false;
if ($template && $isHtml && $this->view && !$this->settings['displayErrorDetails']) {
$response = $this->renderTemplate($request, $response, $template, $code);
} else {
$handler = $this->container['defaultErrorHandler'];
$response = $handler($request, $response, $e);
}
return $response;
}