comparison mod_data_access.wiki @ 241:c6f01319f4c3

Add page about mod_data_access
author Kim Alvefur <zash@zash.se>
date Wed, 07 Dec 2011 18:13:12 +0100
parents
children 963ae0ff05b0
comparison
equal deleted inserted replaced
240:8b15faa008e3 241:c6f01319f4c3
1 #summary HTTP access to prosody’s storage mechanism
2
3 = Introduction =
4
5 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.
6
7 = Syntax =
8
9 To Fetch data, issue a normal GET request
10 {{{
11 GET /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1
12 Authorization: <base64(authzid:password)>
13 [Host: <host>]
14
15 -- OR --
16
17 PUT|POST /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1
18 Content-Type: text/x-lua | application/json
19
20 <data>
21 }}}
22
23 These map to `datamanager.method(user, host, store, data)`, where choice of `method` and its parameters are explained below.
24
25 == Verbs ==
26
27 ||*Verb*||*Meaning* ||*datamanager method* ||
28 ||`GET` || Just fetch data || `load()` or `list_load()` ||
29 ||`PUT` || Replace all data in the store || `store() ||
30 ||`POST`|| Append item to the store || `list_append()` ||
31
32 Note: In a `GET` request, if `load()` returns `nil`, `list_load()` will be tried instead.
33
34 == Fields ==
35
36 ||*Field*||*Description*||*Default*||
37 ||`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.||
38 ||`user`||Which users storage to access||Required. If not set in the path, uses the node part of the authzid.||
39 ||`store`||Which storage to access.||Required.||
40 ||`format`||Which format to serialize to. `json` and `lua` are supported. When uploading data, the `Content-Type` header is used.||`json`||
41 ||`data`||The actual data to upload in a `PUT` or `POST` request.||`nil`||