I see that REST GET request supports the ?run=foo.xq style, which allows a GET to be handled by a pre-defined XQuery file. See http://docs.basex.org/wiki/REST#GET_Requests
However, the REST POST (and other) requests do not support it.
With support for XUpdate in BaseX, it is important to have the ability to POST (or PUT) application-defined data to a server-side XQuery, rather than having the client have to post the entire query. DELETE is useful as well, but takes on data.
See http://docs.basex.org/wiki/REST#POST_Requests
I took a quick look at RESTPost.java and RESTGet.java and see that it would be about 50 lines of work to make RESTPost support making the request entity available to the specified XQuery as context.
Leigh.
I see that REST GET request supports the ?run=foo.xq style, which allows a GET to be handled by a pre-defined XQuery file. See http://docs.basex.org/wiki/REST#GET_Requests
However, the REST POST (and other) requests do not support it.
You may be gratified to hear that POST also supports the RUN operation. I've added a small example to the documentation:
http://docs.basex.org/wiki/REST#POST_Requests
With support for XUpdate in BaseX, it is important to have the ability to POST (or PUT) application-defined data to a server-side XQuery, rather than having the client have to post the entire query.
This is possible by adding a rest:context/ element to your POST request. The element contents will then available as the context item of the server-side query; e.g.:
<rest:run xmlns:rest="http://www.basex.org/rest%22%3E rest:textquery.xq</rest:text> rest:context <xml> <text>Hello</text> <text>World</text> </xml> </rest:context> </rest:run>
Hope this helps, Christian
Thanks, I did see those, but I would like to have the REST way, where the URI identifies the resource, which in this case is defined by an XQuery, and the request entity is the application data.
So,
POST /rest/foo?run=abc.xql <order> <topping>cheese</topping> <topping>pepperoni</topping> </order>
So the RESTPost would support ?run.
A better way might be to allow a separate mapping of resources to XQuery files, so maybe I will take a look at that.
Leigh. On Nov 19, 2011 1:02 PM, "Christian Grün" christian.gruen@gmail.com wrote:
I see that REST GET request supports the ?run=foo.xq style, which allows
a
GET to be handled by a pre-defined XQuery file. See http://docs.basex.org/wiki/REST#GET_Requests
However, the REST POST (and other) requests do not support it.
You may be gratified to hear that POST also supports the RUN operation. I've added a small example to the documentation:
http://docs.basex.org/wiki/REST#POST_Requests
With support for XUpdate in BaseX, it is important to have the ability to POST (or PUT) application-defined data to a server-side XQuery, rather than having the client have to post the entire query.
This is possible by adding a rest:context/ element to your POST request. The element contents will then available as the context item of the server-side query; e.g.:
<rest:run xmlns:rest="http://www.basex.org/rest%22%3E rest:textquery.xq</rest:text> rest:context
<xml> <text>Hello</text> <text>World</text> </xml> </rest:context> </rest:run>
Hope this helps, Christian
basex-talk@mailman.uni-konstanz.de