Hi Christian,
"negotiation code (which got fairly complex, due to all the quality factor checks)."
I had no doubt about this ... and it was confirmed after looking at the code referenceyou attached. I think that server software such as Jetty, Tomcat a.s.o. should provide tools and APIs for managing Content Negotiation OOTB. Nevertheless I installed the new snapshot and now my use case is correctly supported! Thanks a lot for the prompt support as usual! Bis bald, Marco.
On 18/02/21 21:22, Christian Grün wrote:
Hi Marco,
If I specify an explicit %rest:consumes("*/*") in the annotations of fallback(), specific() correctly intercepts the request.
That was misleading: It shouldn’t make a difference if the generic annotation is specified or omitted. This has been fixed.
Unfortunately at that point calling with "Content-Type: text/plain" which should slip through the functions and be catched by fallback() yields instead:
Your observations (and similar ones that we came across in one of our projects) motivated me to have another intense look at the content negotiation code (which got fairly complex, due to all the quality factor checks). I believe I found a solution that matches the requirements without compromising backward compatibility. Details (for those who are interested) can be found in [1].
A new snapshot is available [2], I would be happy if you could test it for us.
Ciao, Christian
[1] https://github.com/BaseXdb/basex/commit/bde52a5ef88e327a7e3f6ad35036cec92767... [2] https://files.basex.org/releases/latest/
declare %rest:path("test") %rest:POST("{$body}") %rest:consumes("text/csv", "application/xml", "application/json") %output:method("text") function s:specific($body as document-node()) { "Treated as document" };
declare %rest:path("test") %rest:POST("{$body}") %output:method("text") function s:fallback($body as item()) { "Treated as binary" };