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" };