Changes

Jump to navigation Jump to search
391 bytes removed ,  21:08, 11 December 2014
Whenever a RESTXQ URL is requested, the [[Options#RESTXQPATH|RESTXQPATH]] module directory and its sub-directories will be parsed for functions with RESTXQ annotations in library modules (detected by the extension {{Code|.xqm}}) and main modules (detected by {{Code|.xq}}). In main expressions, the main module will never be evaluated. All modules will be cached and parsed again when their timestamp changes.
A simple first RESTXQ module function is shown below. It is part of a clean installation and available at http://localhost:8984/ .
<pre class="brush:xquery">(: simplified version of the function found in webapp/restxq.xqm :)
module namespace page = 'http://basex.org/examples/web-page';
declare %rest:path("hello/{$worldwho}") %rest:GET %rest:header-param("User-Agent", "{$agent}") function page:hello($world as xs:string, $agent as xs:string*who) {
<response>
<title>Hello { $world who }!</title> <info>You requested this page with { $agent }.</info>
</response>
};</pre>
If the URI http://localhost:8984/hello/World is accessed, the result will be similar to:
<pre class="brush:xml">
&lt;response&gt;
&lt;title&gt;Hello World!&lt;/title&gt;
&lt;time&gt;The current time is: 18:42:02.306+02:00&lt;/time&gt;
&lt;/response&gt;
</pre>
The RESTXQ module contains yet another next functiondemonstrates a POST request:
<pre class="brush:xquery">
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu