Changes

Jump to navigation Jump to search
7 bytes added ,  19:49, 1 July 2013
no edit summary
</rest:response>
</pre>
 
==Forward and Redirect===
 
The two XML elements <code>rest:forward</code> and <code>rest:redirect</code> can be used 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 a URL to a RESTXQ path. The wrapped URL should be properly encoded via <code>fn:encode-for-uri()</code>.
 
Note that, currently, these elements are not part of RESTXQ specification.
 
===rest:forward===
 
Usage: wrap the location as follows
<pre class="brush:xml"><rest:forward>{ $location }</rest:forward></pre>
 
This results in a server-side forwarding, which as well reduces traffic among client and server. A forwarding of this kind will not change the URL seen from the client's perspective.
 
As an example, returning
<pre class="brush:xml">
<rest:forward>/restxq/hello/universe</rest:forward>
</pre>
would internally forward to http://localhost:8984/restxq/hello/universe
 
===rest:redirect===
 
<pre class="brush:xml"><rest:redirect>{ $location }</rest:redirect></pre>
 
…is basically an abbreviation for…
 
<pre class="brush:xml">
<rest:response>
<http:response status="302" message="Temporary Redirect">
<http:header name="location" value="{ $location }"/>
</http:response>
</rest:response>
</pre>
 
The client decides whether to follow this redirection. Browsers usually will, tools like [http://curl.haxx.se/ curl] won’t unless {{Code|-L}} is specified.
=Output=
};
</pre>
 
=Forward and Redirect=
 
The two XML elements <code>rest:forward</code> and <code>rest:redirect</code> can be used 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 a URL to a RESTXQ path. The wrapped URL should be properly encoded via <code>fn:encode-for-uri()</code>.
 
Note that, currently, these elements are not part of RESTXQ specification.
 
==rest:forward==
 
Usage: wrap the location as follows
<pre class="brush:xml"><rest:forward>{ $location }</rest:forward></pre>
 
This results in a server-side forwarding, which as well reduces traffic among client and server. A forwarding of this kind will not change the URL seen from the client's perspective.
 
As an example, returning
<pre class="brush:xml">
<rest:forward>/restxq/hello/universe</rest:forward>
</pre>
would internally forward to http://localhost:8984/restxq/hello/universe
 
==rest:redirect==
 
<pre class="brush:xml"><rest:redirect>{ $location }</rest:redirect></pre>
 
…is basically an abbreviation for…
 
<pre class="brush:xml">
<rest:response>
<http:response status="302" message="Temporary Redirect">
<http:header name="location" value="{ $location }"/>
</http:response>
</rest:response>
</pre>
 
The client decides whether to follow this redirection. Browsers usually will, tools like [http://curl.haxx.se/ curl] won’t unless {{Code|-L}} is specified.
=References=
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu