Returning multi-part MIME in RESTXQ? Query parameters?
I'm having fun with RESTXQ, this is an easy and efficient way to create REST interfaces once you learn how.
Two questions:
1. How do I return a forest of elements? Multi-part MIME types? If so, how do I specify that? What do I need to add to this particular declaration?
(:~
Look up all entries in the Abbott-Smith lexicon that contain an English
word in the gloss.
:)
declare
%rest:path("/api/abbott-smith/gloss/{$g}")
%rest:GET
%output:method('xml')
function as:gloss($g)
{
$as:abbott-smith/*:entry[.//*:gloss[contains-token(lower-case(.),
lower-case($g))] ]
};2. Can I use query strings to specify parameters in RESTXQ? What if I want URLs like this:
/api/dictionary/?lemma=cheese
Thanks!
Jonathan
Hi Jonathan,
Quoted text · Jonathan Robie · 1 line
> 1. How do I return a forest of elements?
It depends ;) What will your client do with the response? If you talk about a »forest of elements«, is it equivalent to a »sequence of elements«?
Quoted text · Jonathan Robie · 1 line
> 2. Can I use query strings to specify parameters in RESTXQ? What if I want URLs like this:
Absolutely. I hope that our documentation gives you some clues on how to proceed.
Best, Christian
Written for BaseX 9.6. BaseX may have changed since: please check the current documentation.