public function execute(ServerHttpRequest $httpRequest) : HttpResponse
 {
     try {
         return $this->application->execute($httpRequest);
     } catch (\Throwable $exception) {
         $this->log(LogLevel::CRITICAL, $exception->getMessage());
         return new JsonApiErrorResponse(['title' => 'Fatal error'], 500);
     }
 }
Beispiel #2
0
 public function execute(ServerHttpRequest $httpRequest) : HttpResponse
 {
     // When on HTTP: force redirect to HTTPS
     $uri = $httpRequest->getUri();
     if ($uri->getScheme() === 'http') {
         return $this->httpsRedirect($uri);
     }
     // Execute request using the decorated application
     $httpResponse = $this->application->execute($httpRequest);
     return $httpResponse->withHeader('Strict-Transport-Security', $this->buildHeaderValue());
 }
 /** {@inheritdoc} */
 public function execute(ServerHttpRequest $httpRequest) : HttpResponse
 {
     // Only works on requests with non-empty JSON bodies
     if ($httpRequest->getHeaderLine('Content-Type') !== 'application/vnd.api+json' || $httpRequest->getBody()->getSize() === 0) {
         return $this->application->execute($httpRequest);
     }
     $parsedBody = json_decode($httpRequest->getBody()->getContents(), true);
     if (json_last_error() !== JSON_ERROR_NONE) {
         return new JsonApiErrorResponse([['title' => 'Invalid JSON, couldn\'t decode.', 'status' => '400']], 400);
     }
     return $this->application->execute($httpRequest->withParsedBody($parsedBody));
 }
Beispiel #4
0
 public function execute(ServerHttpRequest $httpRequest) : HttpResponse
 {
     $response = $this->application->execute($httpRequest);
     return $this->cspBuilder->injectCSPHeader($response);
 }