function NegotiationMiddleware::handle
Same name in other branches
- 9 core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
- 8.9.x core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php \Drupal\Core\StackMiddleware\NegotiationMiddleware::handle()
- 10 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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.