To try this example, you need GNU make
and git
in your PATH
.
If you don’t have HTTPie installed, use the appropriate cURL commands instead.
To build the example, run the following command:
make
To start the release in the foreground:
./_rel/echo-post-example/bin/echo-post-example console
Note: The previous command also starts an Erlang console.
To start the app and an LFE shell:
lfe -pa ebin -pa deps/*/ebin -s echo-post # make dev
As this example echoes a POST parameter, it is a little more complex to test. Some browsers feature tools that allow you to perform one such request, or you can use the command line tool `http` as we will demonstrate.
http -vf POST :8080 echo=echomeplz
POST / HTTP/1.1
Content-Length: 14
Accept-Encoding: gzip, deflate
Host: localhost:8080
Accept: */*
User-Agent: HTTPie/0.9.2
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=utf-8
echo=echomeplz
HTTP/1.1 200 OK
server: Cowboy
date: Sat, 02 Jan 2016 12:20:50 GMT
content-length: 9
content-type: text/plain; charset=utf-8
echomeplz