Database Reference
In-Depth Information
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f8091007200) send_pipe: 1, recv_pipe: 0
* Connected to localhost (::1) port 8080 (#0)
> GET /exist/restxq/any/thing/at/all HTTP/1.1
> User-Agent: curl/7.32.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sun, 20 Oct 2013 13:01:17 GMT
< Set-Cookie: JSESSIONID=bzhhe8x66jqb1wremvc814vah;Path=/exist
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Content-Type: application/xml
< Transfer-Encoding: chunked
* Server Jetty(8.1.9.v20130131) is not blacklisted
< Server: Jetty(8.1.9.v20130131)
<
* Connection #0 to host localhost left intact
<result>The requested page could not be found!</result>
Note the HTTP response is 200 OK . This is not ideal for when we do not find a
document; 404 Not Found would be more appropriate!
The response media type is application/xml , which is the default of RESTXQ.
The result of the XQuery function.
Example 9-4 has some shortcomings, in that it only handles HTTP GET requests, it
returns the wrong HTTP status code when a document is not found, and it assumes
that the client wants an XML response when a document is not found. Example 9-5
shows an improved version.
Example 9-5. Simple resource function that creates an HTML response
xquery version "3.0";
module namespace ex = "http://example/restxq/2";
import module namespace rest = "http://exquery.org/ns/restxq";
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare
%rest:GET
%rest:HEAD
%rest:POST
%rest:PUT
%rest:DELETE
%output:method("html5")
Search WWH ::




Custom Search