Returning multi-part MIME in RESTXQ? Query parameters?

Friday, 12 November 2021 · 2 messages · last reply 15 Nov 2021
JR
Jonathan Robie12 Nov 2021 22:19 #
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
CG
Christian Grün15 Nov 2021 10:44 #
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 [1] https://docs.basex.org/wiki/RESTXQ#Query_Parameters

⚡Generated with XQuery