From 7a7e144a0d79767f726ca9988a7b8fc752f998ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sun, 8 Sep 2013 19:50:31 +0200 Subject: Convert the REST streaming example to a release --- examples/rest_stream_response/README.md | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'examples/rest_stream_response/README.md') diff --git a/examples/rest_stream_response/README.md b/examples/rest_stream_response/README.md index 70e1ba7..90004e6 100644 --- a/examples/rest_stream_response/README.md +++ b/examples/rest_stream_response/README.md @@ -1,26 +1,34 @@ -Cowboy REST Streaming Responses -=============================== +REST streaming example +====================== -To compile this example you need rebar in your PATH. +To try this example, you need GNU `make`, `git` and +[relx](https://github.com/erlware/relx) in your PATH. -Type the following command: -``` -$ rebar get-deps compile -``` +To build the example, run the following command: -You can then start the Erlang node with the following command: +``` bash +$ make ``` -./start.sh + +To start the release in the foreground: + +``` bash +$ ./_rel/bin/rest_stream_response_example console ``` +Then point your browser at [http://localhost:8080](http://localhost:8080). + +About +----- + This example simulates streaming a large amount of data from a data store one record at a time in CSV format. It also uses a constraint to ensure that the last segment of the route is an integer. -Examples --------- +Example output +-------------- -### Get records with a field 2 value of 1 +Fetch records with the second field with value 1: ``` bash $ curl -i localhost:8080 @@ -37,7 +45,7 @@ DAYEFxER,1,18 ... ``` -### Get records with a field 2 value of 4 +Fetch records with the second field with value 4: ``` bash $ curl -i localhost:8080/4 @@ -54,7 +62,7 @@ CA8BBhYD,4,10 ... ``` -### Get a 404 +Fail to use a proper integer and get an error: ``` bash $ curl -i localhost:8080/foo @@ -63,4 +71,5 @@ connection: keep-alive server: Cowboy date: Sun, 10 Feb 2013 19:36:16 GMT content-length: 0 + ``` -- cgit v1.2.3