-
Notifications
You must be signed in to change notification settings - Fork 2
/
controller.xql
50 lines (43 loc) · 2.07 KB
/
controller.xql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
xquery version "3.0";
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
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="exist.jnlp"/>
</dispatch>
else if( ends-with($exist:resource , ".jnlp")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/jnlp.xq">
<set-attribute name="controller" value="{$exist:controller}"/>
<set-attribute name="prefix" value="{$exist:prefix}"/>
<set-attribute name="resource" value="{$exist:resource}"/>
<set-attribute name="path" value="{$exist:path}"/>
<set-attribute name="root" value="{$exist:root}"/>
</forward>
</dispatch>
else if (ends-with($exist:resource, ".xq")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<set-header name="Cache-Control" value="no-cache"/>
</dispatch>
else if (ends-with($exist:resource, ".jar")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{$exist:resource}.pack.gz"/>
</dispatch>
else if (ends-with($exist:resource, ".pack.gz")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/download.xq">
<set-attribute name="controller" value="{$exist:controller}"/>
<set-attribute name="prefix" value="{$exist:prefix}"/>
<set-attribute name="resource" value="{$exist:resource}"/>
<set-attribute name="path" value="{$exist:path}"/>
<set-attribute name="root" value="{$exist:root}"/>
</forward>
</dispatch>
else
(: everything is passed through :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</dispatch>