xquery version "3.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";
import module namespace restxq="http://exist-db.org/xquery/restxq" at "../demo/modules/restxq.xql";
import module namespace risten="http://exist-db.org/apps/risten" at "modules/risten.xql";
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;
(:
if ($exist:path eq "") then
:)
if ($exist:path eq "/") then
(: Protected resource: user is required to log in with valid credentials.
If the login fails or no credentials were provided, the request is redirected
to the login.html page. :)
(:
else if ($exist:resource eq 'protected.html') then (
login:set-user("org.exist.demo.login", (), false()),
if (request:get-attribute("org.exist.demo.login.user")) then
else
)
:)
(: Pass all requests to HTML files through view.xql, which handles HTML templating :)
else if (ends-with($exist:resource, ".html")) then
else if (contains($exist:path, "/$shared/")) then
(: images, css are contained in the top /resources/ collection. :)
(: Relative path requests from sub-collections are redirected there :)
else if (contains($exist:path, "/resources/")) then
else