mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Convert the compressed response example to a release
This commit is contained in:
parent
4b20f5cd08
commit
2f25c654b0
6 changed files with 37 additions and 34 deletions
14
examples/compress_response/Makefile
Normal file
14
examples/compress_response/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
|||
PROJECT = compress_response
|
||||
|
||||
DEPS = cowboy
|
||||
dep_cowboy = pkg://cowboy master
|
||||
|
||||
.PHONY: release clean-release
|
||||
|
||||
release: clean-release all
|
||||
relx
|
||||
|
||||
clean-release:
|
||||
rm -rf _rel
|
||||
|
||||
include ../../erlang.mk
|
|
@ -1,22 +1,27 @@
|
|||
Cowboy Compress Response
|
||||
========================
|
||||
Compressed response 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:
|
||||
|
||||
``` bash
|
||||
$ make
|
||||
```
|
||||
|
||||
You can then start the Erlang node with the following command:
|
||||
```
|
||||
./start.sh
|
||||
To start the release in the foreground:
|
||||
|
||||
``` bash
|
||||
$ ./_rel/bin/compress_response_example console
|
||||
```
|
||||
|
||||
Then point your browser to the indicated URL.
|
||||
Then point your browser at [http://localhost:8080](http://localhost:8080).
|
||||
|
||||
Example
|
||||
-------
|
||||
Example output
|
||||
--------------
|
||||
|
||||
Without compression:
|
||||
|
||||
``` bash
|
||||
$ curl -i http://localhost:8080
|
||||
|
@ -38,7 +43,11 @@ have established the ability to work at virtually identical tasks and obtained
|
|||
considerable respect for their achievements. There are also cattle handlers
|
||||
in many other parts of the world, particularly South America and Australia,
|
||||
who perform work similar to the cowboy in their respective nations.
|
||||
```
|
||||
|
||||
With compression:
|
||||
|
||||
```
|
||||
$ curl -i --compressed http://localhost:8080
|
||||
HTTP/1.1 200 OK
|
||||
connection: keep-alive
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{deps, [
|
||||
{cowboy, ".*",
|
||||
{git, "git://github.com/extend/cowboy.git", "master"}}
|
||||
]}.
|
2
examples/compress_response/relx.config
Normal file
2
examples/compress_response/relx.config
Normal file
|
@ -0,0 +1,2 @@
|
|||
{release, {compress_response_example, "1"}, [compress_response]}.
|
||||
{extended_start_script, true}.
|
|
@ -1,15 +0,0 @@
|
|||
%% Feel free to use, reuse and abuse the code in this file.
|
||||
|
||||
-module(compress_response).
|
||||
|
||||
%% API.
|
||||
-export([start/0]).
|
||||
|
||||
%% API.
|
||||
|
||||
start() ->
|
||||
ok = application:start(crypto),
|
||||
ok = application:start(cowlib),
|
||||
ok = application:start(ranch),
|
||||
ok = application:start(cowboy),
|
||||
ok = application:start(compress_response).
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
erl -pa ebin deps/*/ebin -s compress_response \
|
||||
-eval "io:format(\"Point your browser at http://localhost:8080~n\")."
|
Loading…
Add table
Add a link
Reference in a new issue