ledisdb/server/http
silentsai 14767ecadb abstract the read / write in server client 2014-07-31 14:38:20 +08:00
..
base.go add unit test 2014-07-25 15:18:39 +08:00
base_test.go add unit test 2014-07-25 15:18:39 +08:00
cmd_bit.go unit tests of cmd_bit 2014-07-24 17:19:44 +08:00
cmd_bit_test.go add unit test 2014-07-25 16:17:45 +08:00
cmd_hash.go unit test for cmd_hash.go 2014-07-25 11:55:56 +08:00
cmd_hash_test.go add unit test 2014-07-25 16:17:45 +08:00
cmd_kv.go complete apis for the rest of cmds 2014-07-24 11:29:13 +08:00
cmd_kv_test.go add unit test 2014-07-25 16:17:45 +08:00
cmd_list.go complete apis for the rest of cmds 2014-07-24 11:29:13 +08:00
cmd_list_test.go add unit tests 2014-07-25 17:27:07 +08:00
cmd_zset.go modify error msg 2014-07-24 11:41:53 +08:00
cmd_zset_test.go unit test of zset 2014-07-28 16:35:46 +08:00
handler.go cancel supporting websocket 2014-07-29 11:02:13 +08:00
http_io.go abstract the read / write in server client 2014-07-31 14:38:20 +08:00
readme.md Update readme.md 2014-07-29 15:33:35 +08:00

readme.md

##HTTP Interface LedisDB provides http interfaces for most commands. ####Request The proper url format is

http://host:port[/db]/cmd/arg1/arg2/.../argN[?type=type]

'db' and 'type' are optional. 'db' stands for ledis db index, ranges from 0 to 15, its default value is 0. 'type' is a custom content type, can be json, bson or msgpack, json is default.

####Response

The response format is

{ cmd: return_value }

or

{ cmd: [success, message] }

'return_value' stands for the output of 'cmd', it can be a number, a string, a list, or a hash. If the return value is just a descriptive message, the second format will be taken, and 'success', a boolean value, indicates whether it is successful.

####Example #####Curl

curl http://127.0.0.1:11181/SET/hello/world
→ {"SET":[true,"OK"]}

curl http://127.0.0.1:11181/0/GET/hello?type=json
→ {"GET":"world"}

#####Python Requires msgpack-python and requests

>>> import requests
>>> import msgpack

>>> requests.get("http://127.0.0.1:11181/0/SET/hello/world")
>>> r = requests.get("http://127.0.0.1:11181/0/GET/hello?type=msgpack")
>>> msgpack.unpackb(r.content) 
>>> {"GET":"world"}