You are here

public function FormatSetter::handle in JSON:API 8.2

Same name and namespace in other branches
  1. 8 src/StackMiddleware/FormatSetter.php \Drupal\jsonapi\StackMiddleware\FormatSetter::handle()

File

src/StackMiddleware/FormatSetter.php, line 40

Class

FormatSetter
Sets the 'api_json' for requests with a JSON:API Content-Type header.

Namespace

Drupal\jsonapi\StackMiddleware

Code

public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
  $accepted = AcceptHeader::fromString($request->headers
    ->get('Accept'));
  if ($accepted
    ->get('application/vnd.api+json')) {
    $request
      ->setRequestFormat('api_json');
  }
  return $this->httpKernel
    ->handle($request, $type, $catch);
}