public function NegotiationMiddleware::handle in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
- 9 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
File
- core/
lib/ Drupal/ Core/ StackMiddleware/ NegotiationMiddleware.php, line 41
Class
- NegotiationMiddleware
- Provides a middleware to determine the content type upon the accept header.
Namespace
Drupal\Core\StackMiddlewareCode
public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
// Register available mime types.
foreach ($this->formats as $format => $mime_type) {
$request
->setFormat($format, $mime_type);
}
// Determine the request format using the negotiator.
if ($requested_format = $this
->getContentType($request)) {
$request
->setRequestFormat($requested_format);
}
return $this->app
->handle($request, $type, $catch);
}