Changes

Jump to navigation Jump to search
1,461 bytes added ,  15:11, 10 November 2012
added restxq:forward and restxq:redirect
};
</pre>
 
 
 
=Forward and Redirect=
With {{Version|7.5}} we introduce two XML elements: <code>restxq:forward</code> and <code>restxq:response</code>. They are not part of RESTXQ-spec and can be returned in the context of [[Web Application]]s, precisely in the context of RESTXQ.
These nodes allow e.g. multiple [[XQuery Update]]s in a row by redirecting to the RESTXQ path of updating functions. Both wrap an URL to a RESTXQ path.
 
Remember to encode the wrapped URL, e.g. using <code>fn:encode-for-uri()</code>.
 
==<code>restxq:forward</code>==
Usage: wrap the location as follows
<pre class="brush:xquery"><restxq:forward>{ $location }</restxq:forward></pre>
 
This results in a serverside forwarding, which as well reduces traffic among client and server. A forward of this kind will not change the URL seen from the clients perspective.
 
As an example, returning
<pre class="brush:xml">
<restxq:forward>/restxq/hello/universe</restxq:forward>
</pre>
would internally forward to http://localhost:8984/restxq/hello/universe
 
==<code>restxq:redirect</code>==
 
<pre class="brush:xquery"><restxq:redirect>{ $location }</restxq:redirect></pre>
 
which is an abbreviation for
 
<pre class="brush:xquery">
<restxq:response>
<http:response status="302" message="Temporary Redirect">
<http:header name="location" value="{ $location }"/>
</http:response>
</restxq:response>
</pre>
 
The client decides wether to follow this redirect, Browsers usually will, curl will not.
 
 
=References=
editor, reviewer
115

edits

Navigation menu