# HG changeset patch # User Kim Alvefur # Date 1323277992 -3600 # Node ID c6f01319f4c34739b097c9f70d6d47651bd972d7 # Parent 8b15faa008e3d7c4e81cf34165c7b0317ee8bdf9 Add page about mod_data_access diff -r 8b15faa008e3 -r c6f01319f4c3 mod_data_access.wiki --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_data_access.wiki Wed Dec 07 18:13:12 2011 +0100 @@ -0,0 +1,41 @@ +#summary HTTP access to prosody’s storage mechanism + += Introduction = + +This module gives HTTP access to prosody’s storage mechanism. It uses normal HTTP verbs and [http://tools.ietf.org/html/rfc2617 Basic HTTP authentication], so you could call it RESTful if you like buzzwords. + += Syntax = + +To Fetch data, issue a normal GET request +{{{ + GET /data[//]/[/] HTTP/1.1 + Authorization: + [Host: ] + + -- OR -- + + PUT|POST /data[//]/[/] HTTP/1.1 + Content-Type: text/x-lua | application/json + + +}}} + +These map to `datamanager.method(user, host, store, data)`, where choice of `method` and its parameters are explained below. + +== Verbs == + +||*Verb*||*Meaning* ||*datamanager method* || +||`GET` || Just fetch data || `load()` or `list_load()` || +||`PUT` || Replace all data in the store || `store() || +||`POST`|| Append item to the store || `list_append()` || + +Note: In a `GET` request, if `load()` returns `nil`, `list_load()` will be tried instead. + +== Fields == + +||*Field*||*Description*||*Default*|| +||`host`||Which virtual host to access||Required. If not set in the path, the `Host` header is used. If that's not set either, the domain-part of the authzid is used.|| +||`user`||Which users storage to access||Required. If not set in the path, uses the node part of the authzid.|| +||`store`||Which storage to access.||Required.|| +||`format`||Which format to serialize to. `json` and `lua` are supported. When uploading data, the `Content-Type` header is used.||`json`|| +||`data`||The actual data to upload in a `PUT` or `POST` request.||`nil`||