NegotiationMiddleware
class NegotiationMiddleware implements HttpKernelInterface (View source)
Provides a middleware to determine the content type upon the accept header.
Properties
| protected HttpKernelInterface | $app | The wrapped HTTP kernel. |
|
| protected array | $formats | Contains a hashmap of format as key and mimetype as value. |
Methods
__construct(HttpKernelInterface $app)
Constructs a new NegotiationMiddleware.
Response
handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
{@inheritdoc}
$this
registerFormat(string $format, string $mime_type)
Registers a format for a given MIME type.
string
getContentType(Request $request)
Gets the normalized type of a request.
Details
__construct(HttpKernelInterface $app)
Constructs a new NegotiationMiddleware.
Response
handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
{@inheritdoc}
$this
registerFormat(string $format, string $mime_type)
Registers a format for a given MIME type.
protected string
getContentType(Request $request)
Gets the normalized type of a request.
The normalized type is a short, lowercase version of the format, such as 'html', 'json' or 'atom'.