I assume the mapping is static (does not change at runtime). Then you can either override the media type in a pre-matching (!) filter (otherwise it is simply too late), or you can simply get rid of the filter and just use two @GET methods having distinct @Produces annotations and distinct @Path("key.json) annotations (Jersey will do the rest).
-Markus
-----Ursprüngliche Nachricht-----
Von: ganges [mailto:katakam.g_at_gmail.com]
Gesendet: Montag, 7. März 2016 03:05
An: users_at_jersey.java.net
Betreff: [Jersey] Overriding mediaType extensions using Filters
Hi,
We are actually mapping the media types with the uri suffix's.
Map<String, MediaType> type = config.getMediaTypeMappings(); type.put("json", MediaType.APPLICATION_JSON_TYPE); type.put("xml", MediaType.APPLICATION_XML_TYPE);
And i have a resource which @Produces "application/xml".
Now, my requirement to send the response in application/xml format for the uri's ending with suffix myhost.com/key.json
Since i have mapped the suffix's with media types which is always producing the JSON in this case.
Also, i have observed the Accepts is ignored in my request header.
I can't turn off the mediatype mapping as some of the resources need to produce application/json for json uri suffixes.
Is there a way i can fix this?
--
View this message in context: http://jersey.576304.n2.nabble.com/Overriding-mediaType-extensions-using-Filters-tp7583633.html
Sent from the Jersey mailing list archive at Nabble.com.