本文整理匯總了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;
}