XQRS: XQuery API for RESTful Web Services is a
RESTXQ
implementation for MarkLogic Server.
It's fast, scales and
is light weight at around 1.1k lines of code.
You can seamlessly add it to your existing project without it
interfering. Support is available on GitHub.
RESTXQ enables you to build RESTful services declaratively with XQuery Annotations in the same way
as JAX-RS
does for Java.
Create RESTful Services with URIs that work exactly how you want them to
declare
%rest:path("/factory/warehouse/wheel/{$wheel-id}")
%rest:GET
function get-wheel($wheel-id as xs:string) {
fn:doc($wheel-id)
};
declare
%rest:path("/factory/warehouse/wheel/{$wheel-id}")
%rest:PUT("{$doc}")
%xdmp:update
function put-wheel($wheel-id as xs:string, $doc as document-node(element())) {
xdmp:document-insert($wheel-id, $doc, map:entry("collections", "wheels"))
};
declare
%rest:path("/factory/warehouse/wheel")
function list-wheels() {
<wheels>{
fn:collection("wheels")
}</wheels>
};
Adam Retter introduced the idea of creating RESTful Services in XQuery with Annotations at XML Prague 2012 and then with Christian Grün managed to flesh out the RESTXQ Specification.