mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Convert the chunked hello world example to a release
This commit is contained in:
parent
bb9a2e975e
commit
4b20f5cd08
6 changed files with 33 additions and 35 deletions
14
examples/chunked_hello_world/Makefile
Normal file
14
examples/chunked_hello_world/Makefile
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
PROJECT = chunked_hello_world
|
||||||
|
|
||||||
|
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,26 @@
|
||||||
Cowboy Chunked Hello World
|
Chunked hello world 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:
|
To build the example, run the following command:
|
||||||
```
|
|
||||||
$ rebar get-deps compile
|
``` bash
|
||||||
|
$ make
|
||||||
```
|
```
|
||||||
|
|
||||||
You can then start the Erlang node with the following command:
|
To start the release in the foreground:
|
||||||
```
|
|
||||||
./start.sh
|
``` bash
|
||||||
|
$ ./_rel/bin/chunked_hello_world_example console
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run the given command or point your browser to the indicated URL.
|
Then point your browser at [http://localhost:8080](http://localhost:8080),
|
||||||
|
or use `curl` to see the chunks arriving one at a time every second.
|
||||||
|
|
||||||
Example
|
Example output
|
||||||
-------
|
--------------
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
$ time curl -i http://localhost:8080
|
$ time curl -i http://localhost:8080
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
{deps, [
|
|
||||||
{cowboy, ".*",
|
|
||||||
{git, "git://github.com/extend/cowboy.git", "master"}}
|
|
||||||
]}.
|
|
2
examples/chunked_hello_world/relx.config
Normal file
2
examples/chunked_hello_world/relx.config
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{release, {chunked_hello_world_example, "1"}, [chunked_hello_world]}.
|
||||||
|
{extended_start_script, true}.
|
|
@ -1,15 +0,0 @@
|
||||||
%% Feel free to use, reuse and abuse the code in this file.
|
|
||||||
|
|
||||||
-module(chunked_hello_world).
|
|
||||||
|
|
||||||
%% 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(chunked_hello_world).
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
erl -pa ebin deps/*/ebin -s chunked_hello_world \
|
|
||||||
-eval "io:format(\"Run: curl -i http://localhost:8080~n\")."
|
|
Loading…
Add table
Add a link
Reference in a new issue