Exemple #1
0
 /**
  *
  */
 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;
 }
 /**
  * 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;
 }
Exemple #3
0
 /**
  * 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;
 }