xquery version "1.0";
declare namespace json="http://www.json.org";
declare namespace output="http://exquery.org/ns/rest/annotation/output";
declare namespace rest="http://exquery.org/ns/restxq";
(:
: Main controller. Uses restxq to keep the code clean. This only works with the XQuery
: implementation of RestXQ though.
:)
import module namespace restxq="http://exist-db.org/xquery/restxq" at "../../demo/modules/restxq.xql";
import module namespace ristenxq="http://exist-db.org/apps/restxq/ristenxq" at "restxq-risten.xql";
(: Need to use a different namespace here to prevent the restxq java triggger
: from evaluating the annotations. :)
declare namespace restx="http://exist-db.org/ns/rest/annotation/xquery";
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;
(:~
: Redirect requests for / to demo.html.
:)
(:
if ($exist:path = "/") then
:)
if (ends-with($exist:path, ".html")) then
else if (starts-with($exist:path, ("/risten/"))) then
let $functions := util:list-functions("http://exist-db.org/apps/restxq/ristenxq")
return
(: All URL paths are processed by the restxq module :)
restxq:process($exist:path, $functions)
(:
else if (starts-with($exist:path, "/resources")) then
(: images, css are contained in the top /resources/ collection. :)
(: Relative path requests from sub-collections are redirected there :)
:)
else