comparison mod_data_access.wiki @ 249:963ae0ff05b0

Add page for mod_mam
author Kim Alvefur <zash@zash.se>
date Fri, 06 Jan 2012 16:52:20 +0100
parents c6f01319f4c3
children
comparison
equal deleted inserted replaced
248:7a0d1a7355f4 249:963ae0ff05b0
8 8
9 To Fetch data, issue a normal GET request 9 To Fetch data, issue a normal GET request
10 {{{ 10 {{{
11 GET /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1 11 GET /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1
12 Authorization: <base64(authzid:password)> 12 Authorization: <base64(authzid:password)>
13 [Host: <host>]
14 13
15 -- OR -- 14 -- OR --
16 15
17 PUT|POST /data[/<host>/<user>]/<store>[/<format>] HTTP/1.1 16 PUT|POST /data[/<host>/<user>]/<store> HTTP/1.1
18 Content-Type: text/x-lua | application/json 17 Content-Type: text/x-lua | application/json
19 18
20 <data> 19 <data>
21 }}} 20 }}}
22 21
32 Note: In a `GET` request, if `load()` returns `nil`, `list_load()` will be tried instead. 31 Note: In a `GET` request, if `load()` returns `nil`, `list_load()` will be tried instead.
33 32
34 == Fields == 33 == Fields ==
35 34
36 ||*Field*||*Description*||*Default*|| 35 ||*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.|| 36 ||`host`||Which virtual host to access||Required. If not set in the path, 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.|| 37 ||`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.|| 38 ||`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`|| 39 ||`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`|| 40 ||`data`||The actual data to upload in a `PUT` or `POST` request.||`nil`||
41
42 Note: Only admins can change data for users other than themselves.
43
44 == Example usage ==
45
46 Here follows some example usage using `curl`.
47
48 Get your account details:
49
50 {{{
51 curl http://prosody.local:5280/data/accounts -u user@example.com:secr1t
52 {"password":"secr1t"}
53 }}}
54
55 Set someones account details:
56
57 {{{
58 curl -X PUT http://prosody.local:5280/data/example.com/user/accounts -u admin@host:r00tp4ssw0rd --header 'Content-Type: application/json' --data-binary '{"password":"changeme"}'
59 }}}
60
61 == Client library ==
62
63 * https://metacpan.org/module/Prosody::Mod::Data::Access
64
65 == TODO ==
66
67 * Use `Accept` header.