Database Reference
In-Depth Information
The /db on the end of the URI indicates the root collection in the database. When the
REST Server receives an HTTP GET request (e.g., a typical request from a web
browser such as Firefox or Chrome) for a collection URI in the database, it will by
default produce a listing of the resources and subcollections in that collection in
XML, as seen in Figure 13-15 .
You can disable the collection listing provided by the REST Server;
see “Disabling direct access to the REST Server” on page 180 .
Figure 13-15. Browsing the REST Server API with the Chrome web browser
When accessing a collection from the REST Server, rather than listing the collection
contents, you can present a document (or anything, really) instead by executing an
XQuery known as a default document . You can enable default documents by adding
mappings in $EXIST_HOME/descriptor.xml and then restarting eXist.
For example, if you wanted to remove the default collection listing response provided
by the REST Server when accessing the collection /db/products , you could add the fol‐
lowing mapping to the maps section of $EXIST_HOME/descriptor.xml :
<map path= "/db/products" view= "/db/products/default.xq" />
then, instead of the collection listing, the result of executing the XQuery /db/products/
default.xq would be returned.
Of course, manipulating the descriptor.xml configuration file is not the only solution
available, but it is simple. If you require something more complex, you can make use
of the full power of eXist's XQuery URL rewriting (see “URL Mapping Using URL
Rewriting” on page 194 ).
 
Search WWH ::




Custom Search