Skip to content

Commit

Permalink
BSON support.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasff committed Feb 1, 2011
1 parent 2a84258 commit e4d2738
Show file tree
Hide file tree
Showing 5 changed files with 482 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
@@ -1,7 +1,7 @@
OUT=webdis
HIREDIS_OBJ=hiredis/hiredis.o hiredis/sds.o hiredis/net.o hiredis/async.o hiredis/dict.o
JANSSON_OBJ=jansson/src/dump.o jansson/src/error.o jansson/src/hashtable.o jansson/src/load.o jansson/src/strbuffer.o jansson/src/utf.o jansson/src/value.o jansson/src/variadic.o
FORMAT_OBJS=formats/json.o formats/raw.o formats/common.o formats/custom-type.o
FORMAT_OBJS=formats/json.o formats/raw.o formats/common.o formats/custom-type.o formats/bson.o
OBJS=webdis.o conf.o $(FORMAT_OBJS) cmd.o slog.o server.o $(HIREDIS_OBJ) $(JANSSON_OBJ) libb64/cencode.o acl.o md5/md5.o

CFLAGS=-O3 -Wall -Wextra -I. -Ijansson/src
Expand Down
2 changes: 2 additions & 0 deletions README.markdown
Expand Up @@ -22,6 +22,7 @@ curl -d "GET/hello" http://127.0.0.1:7379/
* GET and POST are supported.
* JSON output by default, optional JSONP parameter (`?jsonp=myFunction`).
* Raw Redis 2.0 protocol output with `.raw` suffix
* BSON support for compact responses and MongoDB compatibility.
* HTTP 1.1 pipelining (50,000 http requests per second on a desktop Linux machine.)
* Connects to Redis using a TCP or UNIX socket.
* Restricted commands by IP range (CIDR subnet + mask) or HTTP Basic Auth, returning 403 errors.
Expand Down Expand Up @@ -162,6 +163,7 @@ $ curl http://127.0.0.1:7379/MAKE-ME-COFFEE.raw
Several content-types are available:

* `.json` for `application/json` (this is the default Content-Type).
* `.bson` for `application/bson`. See [http://bsonspec.org/](http://bsonspec.org/) for the specs.
* `.txt` for `text/plain`
* `.html` for `text/html`
* `xhtml` for `application/xhtml+xml`
Expand Down
2 changes: 2 additions & 0 deletions cmd.c
Expand Up @@ -4,6 +4,7 @@
#include "acl.h"

#include "formats/json.h"
#include "formats/bson.h"
#include "formats/raw.h"
#include "formats/custom-type.h"

Expand Down Expand Up @@ -209,6 +210,7 @@ cmd_select_format(struct cmd *cmd, const char *uri, size_t uri_len, formatting_f
struct reply_format funs[] = {
{.s = "json", .sz = 4, .f = json_reply, .ct = "application/json"},
{.s = "raw", .sz = 3, .f = raw_reply, .ct = "binary/octet-stream"},
{.s = "bson", .sz = 4, .f = bson_reply, .ct = "application/bson"},

{.s = "bin", .sz = 3, .f = custom_type_reply, .ct = "binary/octet-stream"},
{.s = "txt", .sz = 3, .f = custom_type_reply, .ct = "text/plain"},
Expand Down

0 comments on commit e4d2738

Please sign in to comment.