Changes

Jump to navigation Jump to search
104 bytes added ,  19:50, 1 July 2013
By default, a successful request is answered with the HTTP status code {{Code|200}} (OK), and is followed by the given content; an erroneous request leads to an error code and an optional error message (e.g. {{Code|404}} for “resource not found”).
Custom responses can be built from within XQuery by returning an <code>rest:response</code>element, an <code>http:response</code> child node that matches the syntax of the [http://expath.org/spec/http-client EXPath HTTP Client Module] specification, and more optional child nodes that will be serialized as usual. E.g. one A function that reacts on an unknown resource may return to the clientlook as follows:
<pre class="brush:xmlxquery">declare %rest:path("") function page:404() { <rest:response> <http:response status="404" message="I was not found."> <http:header name="Content-Language" value="en"/> <http:header name="Content-Type" value="text/html; charset=utf-8"/> </http:response> </rest:response>};
</pre>
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu