Closed weierophinney closed 7 years ago
Hi @weierophinney, thanks for this great patch!
I will fix the Appveyor setup and trigger the build again for this PR but looks good to me :)
Thanks!
Released 2.3.0 with this feature!
Hi @willdurand, @weierophinney! This PR and the new release (2.3) breaks our api-platform/core
test suite. See https://travis-ci.org/api-platform/core/jobs/228775063 for example.
I have this accept header: application/hal+json
.
My priorities are:
[0] => "application/ld+json"
[1] => "application/hal+json"
[2] => "application/xml"
[3] => "text/xml"
[4] => "application/json"
[5] => "text/html"
Then, the AbstractNegotiator::getBest()
method now returns application/ld+json
instead of application/hal+json
before.
It looks like something is not working properly here, nop? Thanks.
(Ping @dunglas)
ah :(
A relatively common way to allow negotation to multiple serialization structures for a single media type is to use "+" notation within the mediatype:
application/vnd.book+json
: JSON serialization ofapplication/vnd.book
mediatype.application/vnd.book+xml
: XML serialization ofapplication/vnd.book
mediatype.In particular, this is useful for determining what general serialization is used for an incoming request in order to select an appropriate deserializer.
With the current 2.X branch, I expected the following to work:
However, it failed on each of the cases listed above.
This patch provides additional negotiation routines within
Negotiation\Negotiator::match
in order to allow such negotiation to work as expected.