Hi Mike,
One way of solving this would be to utilize the standard
Request.selectVariant method (see [1]).
You should be able to inject the request instance to your resource
method and pass it your
custom, say variants, Variant list. If the above method returns null,
you hit the case
where the most suitable response would be just:
Response.notAcceptable(variants).build();
HTH,
~Jakub
[1]
http://jsr311.java.net/nonav/javadoc/javax/ws/rs/core/Request.html#selectVariant(java.util.List)
On 7/23/12 9:43 PM, Mike Summers wrote:
> What's a good way to return Response entities that don't cause a
> marshal error on the entity when there's no @Provider that matches the
> Accept header media type?
>
> I don't think I'll be able to get the client to change their Accept to
> something like "Accept: <preferred-type>,application/xml;q=0.9" which
> would solve my problem.
>
> Is there anything smart I can do server side? This only happens in
> error cases, and we have an ExceptionMapper, maybe there's something
> we can do there?
>
> Thanks.