Database Reference
In-Depth Information
function ex:not-found() {
(
<rest:response>
<http:response status="404"/>
</rest:response>
,
<html>
<head><title>Document not found!</title></head>
<body>
<p>Sorry, we could not find the document that you requested :-(</p>
</body>
</html>
)
};
We declare that we wish to process all supported HTTP methods.
We use an output annotation to specify that the body of the response should be
serialized as HTML5. Output annotations are part of the RESTXQ specification
and simply provide an annotation syntax for the XSLT and XQuery 3.0 Serializa‐
tion specification.
We start a sequence , which allows us to control the response from RESTXQ and
provide a response body.
We declare that the HTTP response code should be set to 404 Not Found .
Note the comma that separates the first item in the sequence, which controls the
RESTXQ response, from our response body (the second item in the sequence).
We construct an HTML document for our response body.
Example 9-5 addresses the problems of Example 9-4 by handling all methods and
explicitly defining properties of the HTTP response. We can store it into the data‐
base, replacing the first example, and then access it by requesting any URI (by any
HTTP method) under http://localhost:8080/exist/restxq . For example, using cURL:
$ curl -v -X POST http://localhost:8080/exist/restxq/any/thing/at/all
results in:
* About to connect() to localhost port 8080 (#0)
* Trying ::1...
* Adding handle: conn: 0x7f947b007200
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f947b007200) send_pipe: 1, recv_pipe: 0
* Connected to localhost (::1) port 8080 (#0)
Search WWH ::




Custom Search