webdis: HTTP + JSON API for Redis
HTTP is the dial tone of the web. Apps that speak HTTP tend to grow in popularity, such as CouchDB whose built-in HTTP-based RESTful API makes it super easy to store and retrieve JSON data.
Nicolas Favre-Felix gives some web love to Redis fans with Webdis, an HTTP interface for Redis that serves up JSON. Built in C, Webdis aims to be fast like Redis itself. The URL structure takes the pattern of:
http://127.0.0.1:7379/COMMAND/KEY/[VALUE]
Let’s look at some concrete examples:
curl http://127.0.0.1:7379/SET/hello/world
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:7379/GET/hello
→ {"GET":"world"}
curl -d "GET/hello" http://127.0.0.1:7379/
→ {"GET":"world"}
While still early in development, the feature set is impressive. Webdis currently offers:
- Support for GET and POST
- JSON and JSONP parameter (
?jsonp=myFunction
). - Raw Redis 2.0 protocol output with
.raw
suffix - HTTP 1.1 pipelining
- TCP or UNIX socket Redis connections
- CIDR or HTTP Basic Auth security
- Pub/Sub using
Transfer-Encoding: chunked
. Coupled with JSONP, Webdis can be used as a Comet server - Built-in support for
json
,txt
, ‘html
,xml
,xhtml
,png
, andjpg
- Custom Content-Type types based on file extension, or
?type=some/thing
- Cross-origin XHR, if compiled with libevent2 (for
OPTIONS
support) - File upload with PUT, if compiled with libevent2 (for
PUT
support)
Check the README for the complete list. If you’d like to contribute, Nicolas is thinking about how to add other HTTP verb support like PUT and DELETE, Websockets, and Etags.
Also, if you missed it, be sure and catch episode #45 with @antirez, the creator of Redis.
Discussion
Sign in or Join to comment or subscribe