* Add links to new images on AWS ECR
* Clean up Markdown:
* Change all <pre>...</pre> to ``` blocks
* Add syntax info on code blocks
* Add `$` prefix in front of all commands that didn't have it
* Heading tweak
A very simple web server providing an HTTP interface to Redis. It uses [hiredis](https://github.com/antirez/hiredis), [jansson](https://github.com/akheron/jansson), [libevent](https://monkey.org/~provos/libevent/), and [http-parser](https://github.com/ry/http-parser/).
Webdis depends on libevent-dev. You can install it on Ubuntu by typing `sudo apt-get install libevent-dev` or on macOS by typing `brew install libevent`.
<pre>
make clean all
```sh
$ make clean all
./webdis &
$ ./webdis &
curl http://127.0.0.1:7379/SET/hello/world
$ curl http://127.0.0.1:7379/SET/hello/world
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:7379/GET/hello
$ curl http://127.0.0.1:7379/GET/hello
→ {"GET":"world"}
curl -d "GET/hello" http://127.0.0.1:7379/
$ curl -d "GET/hello" http://127.0.0.1:7379/
→ {"GET":"world"}
</pre>
```
# Try in Docker
<pre>
```sh
$ docker run --name webdis-test --rm -d -p 7379:7379 nicolas/webdis
* HTTP request limit with `http_max_request_size` (in bytes, set to 128MB by default).
* Database selection in the URL, using e.g. `/7/GET/key` to run the command on DB 7.
# Ideas, TODO...
# Ideas, TODO…
* Add better support for PUT, DELETE, HEAD, OPTIONS? How? For which commands?
* This could be done using a “strict mode” with a table of commands and the verbs that can/must be used with each command. Strict mode would be optional, configurable. How would webdis know of new commands remains to be determined.
* MULTI/EXEC/DISCARD/WATCH are disabled at the moment; find a way to use them.
@ -121,7 +138,7 @@ Access control is configured in `webdis.json`. Each configuration tries to match
Each ACL contains two lists of commands, `enabled` and `disabled`. All commands being enabled by default, it is up to the administrator to disable or re-enable them on a per-profile basis.
Examples:
<pre>
```json
{
"disabled": ["DEBUG", "FLUSHDB", "FLUSHALL"],
},
@ -142,7 +159,7 @@ Examples:
"ip": "192.168.10.0/24",
"enabled": ["SET", "DEL"]
}
</pre>
```
ACLs are interpreted in order, later authorizations superseding earlier ones if a client matches several. The special value "*" matches all commands.
# Environment variables
@ -150,19 +167,18 @@ ACLs are interpreted in order, later authorizations superseding earlier ones if
Environment variables can be used in `webdis.json` to read values from the environment instead of using constant values.
For this, the value must be a string starting with a dollar symbol and written in all caps. For example, to make the redis host and port configurable via environment variables, use the following:
<pre>
```json
{
"redis_host": "$REDIS_HOST",
"redis_port": "$REDIS_PORT",
[...]
}
</pre>
```
# JSON output
JSON is the default output format. Each command returns a JSON object with the command as a key and the result as a value.
Webdis supports file upload using HTTP PUT. The command URI is slightly different, as the last argument is taken from the HTTP body.
For example: instead of `/SET/key/value`, the URI becomes `/SET/key` and the value is the entirety of the body. This works for other commands such as LPUSH, etc.
**Uploading a binary file to webdis**:
<pre>
```
$ file redis-logo.png
redis-logo.png: PNG image, 513 x 197, 8-bit/color RGBA, non-interlaced
The file was uploaded and re-downloaded properly: it has the same hash and the content-type was set properly thanks to the `.png` extension.
@ -318,7 +333,7 @@ Web Sockets are supported with the following formats, selected by the connection
* Raw Redis wire protocol (on `/.raw`)
**Example**:
<pre>
```javascript
function testJSON() {
var jsonSocket = new WebSocket("ws://127.0.0.1:7379/.json");
jsonSocket.onopen = function() {
@ -332,20 +347,20 @@ function testJSON() {
};
}
testJSON();
</pre>
```
This produces the following output:
<pre>
```
JSON socket connected!
JSON received: {"SET":[true,"OK"]}
JSON received: {"GET":"world"}
</pre>
```
# Pub/Sub with chunked transfer encoding
Webdis exposes Redis PUB/SUB channels to HTTP clients, forwarding messages in the channel as they are published by Redis. This is done using chunked transfer encoding.