mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Removed a few lines from the README for pedantic correctness.
This commit is contained in:
parent
078ab340e9
commit
39513deaca
1 changed files with 13 additions and 20 deletions
33
README.md
33
README.md
|
@ -64,28 +64,21 @@ Don't worry about it right now though and continue reading, it'll all
|
||||||
be explained.
|
be explained.
|
||||||
|
|
||||||
You can start and stop listeners by calling `cowboy:start_listener/6` and
|
You can start and stop listeners by calling `cowboy:start_listener/6` and
|
||||||
`cowboy:stop_listener/1` respectively, as demonstrated in the following
|
`cowboy:stop_listener/1` respectively.
|
||||||
example.
|
|
||||||
|
The following example demonstrates the startup of a very simple listener.
|
||||||
|
|
||||||
``` erlang
|
``` erlang
|
||||||
-module(my_app).
|
application:start(cowboy),
|
||||||
-behaviour(application).
|
Dispatch = [
|
||||||
-export([start/2, stop/1]).
|
%% {Host, list({Path, Handler, Opts})}
|
||||||
|
{'_', [{'_', my_handler, []}]}
|
||||||
start(_Type, _Args) ->
|
],
|
||||||
application:start(cowboy),
|
%% Name, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts
|
||||||
Dispatch = [
|
cowboy:start_listener(http, 100,
|
||||||
%% {Host, list({Path, Handler, Opts})}
|
cowboy_tcp_transport, [{port, 8080}],
|
||||||
{'_', [{'_', my_handler, []}]}
|
cowboy_http_protocol, [{dispatch, Dispatch}]
|
||||||
],
|
).
|
||||||
%% Name, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts
|
|
||||||
cowboy:start_listener(http, 100,
|
|
||||||
cowboy_tcp_transport, [{port, 8080}],
|
|
||||||
cowboy_http_protocol, [{dispatch, Dispatch}]
|
|
||||||
).
|
|
||||||
|
|
||||||
stop(_State) ->
|
|
||||||
ok.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This is not enough though, you must also write the my_handler module
|
This is not enough though, you must also write the my_handler module
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue