Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move inline programlistings into includes #930

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ignore xmlns="http://exist.sourceforge.net/NS/exist"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="..."/>
</dispatch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/transform.xq">
<add-parameter name="doc" value="{$exist:resource}.xml"/>
</forward>
</dispatch>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<add-parameter name="xxx" value="yyy"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<set-attribute name="xxx" value="yyy"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<clear-attribute name="xxx">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@duncdrum FYI, this document that I added here wasn't well-formed, so I folded the fix into the rebased #906.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<set-header name="xxx" value="yyy"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="..."/>
<cache-control cache="yes"/>
</dispatch>
25 changes: 8 additions & 17 deletions src/main/xar-resources/data/urlrewrite/urlrewrite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
useful for requests to fixed resources like images or stylesheets. An alternative may be to
handle requests for such resources separately from the <code>XQueryUrlRewrite</code>
servlet; this is discussed in <xref linkend="controller-mappings"/>.</para>
<programlisting language="xml">&lt;ignore xmlns="http://exist.sourceforge.net/NS/exist"/&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-14.xml"/>
<para>The <tag>ignore</tag> element may include an optional <link linkend="cache-control"><literal>cache-control</literal></link> element.</para>
</sect2>
<sect2 xml:id="redirect">
Expand All @@ -143,9 +143,7 @@
request, and this can potentially trigger the controller again; care must be taken to avoid
creaing an un-exitable loop.</para>
<para>The URL to the <literal>redirect</literal> element is given in an attribute named <literal>url</literal>.</para>
<programlisting language="xml">&lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
&lt;redirect url="..."/&gt;
&lt;/dispatch&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-15.xml"/>
<para>A redirect will be visible to the user: for instance the user's web-browser will be
updated to show the specified new URL.</para>
</sect2>
Expand Down Expand Up @@ -205,11 +203,7 @@
</listitem>
</varlistentry>
</variablelist>
<programlisting language="xml">&lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
&lt;forward url="{$exist:controller}/modules/transform.xq"&gt;
&lt;add-parameter name="doc" value="{$exist:resource}.xml"/&gt;
&lt;/forward&gt;
&lt;/dispatch&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-16.xml"/>
<para>The <tag>forward</tag> element can contain the optional child elements: <link
linkend="add-parameter"><literal>add-parameter</literal></link>, <link
linkend="set-attribute"><literal>set-attribute</literal></link>, <link
Expand All @@ -230,7 +224,7 @@
Parameter.</para>
<para>The name of the parameter is taken from the <literal>name</literal> attribute, and the
value from the <literal>value</literal> attribute.</para>
<programlisting language="xml">&lt;add-parameter name="xxx" value="yyy"/&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-17.xml"/>
<para>The original HTTP request will be copied before the change is applied. This applies only
to the step on which it is placed, that is to say that subsequent steps in the pipeline will
not see the parameter. </para>
Expand All @@ -242,7 +236,7 @@
they and are not related to the HTTP Request or HTTP Response.</para>
<para>The name of the request attribute is read from the <literal>name</literal> attribute,
and the value from the <literal>value</literal> attribute.</para>
<programlisting language="xml">&lt;set-attribute name="xxx" value="yyy"/&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-18.xml"/>
<para>You can set arbitrary request attributes, for instance to pass information between
XQuery modules. Some attribute names may be reserved by various servlets in the
pipeline.</para>
Expand All @@ -251,7 +245,7 @@
<para>The <tag>clear-attribute</tag> option clears a request attribute.</para>
<para>The name of the request attribute is read from the <literal>name</literal>
attribute.</para>
<programlisting language="xml">&lt;clear-attribute name="xxx"/&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-19.xml"/>
<para>Unlike parameters, request attributes will be visible to subsequent steps in the
processing pipeline. They only need to be explicitly cleared once they are no longer needed
by the user. eXist-db places no requirement on the user having to ever clear the
Expand All @@ -260,7 +254,7 @@
<para>The <tag>set-header</tag> option sets an HTTP Response Header field.</para>
<para>The name of the header is read from the <literal>name</literal> attribute, and the value
from the <literal>value</literal> attribute.</para>
<programlisting language="xml">&lt;set-header name="xxx" value="yyy"/&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-20.xml"/>
<para>The HTTP response is shared between all steps in the pipeline, so all following steps will be able to see the change.</para></sect2>
<sect2 xml:id="cache-control">
<title>The <tag>cache-control</tag> Option</title>
Expand All @@ -270,10 +264,7 @@
<para>Internally the URL Rewriting framework maintains a mapping between Input URLs and
Dispatch Rules. When the cache is enabled, the <literal>controller.xq</literal> XQuery Main Module only needs to be
executed once for each distinct input URL. Subsequent requests for the same URL will be served from the cache.</para>
<programlisting language="xml">&lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
&lt;redirect url="..."/&gt;
&lt;cache-control cache="yes"/&gt;
&lt;/dispatch&gt;</programlisting>
<programlisting language="xml" xlink:href="listings/listing-21.xml"/>
<para>Note: only the URL rewrite rule is cached, the HTTP response itself is not cached! The <literal>cache-control</literal> setting is unrelated to any HTTP Cache Headers in the HTTP Response, and is unrelated to any client-side caching within a web-browser.</para>
</sect2>
</sect1>
Expand Down
Loading