mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Use syntax highlighted code block in README.md
GitHub just implemented that and we should use it. https://github.com/blog/832-rolling-out-the-redcarpet
This commit is contained in:
parent
20293be912
commit
2c21f0cd09
1 changed files with 23 additions and 19 deletions
|
@ -54,6 +54,7 @@ listener a unique name.
|
|||
|
||||
Code speaks more than words:
|
||||
|
||||
``` erlang
|
||||
application:start(cowboy),
|
||||
Dispatch = [
|
||||
%% {Host, list({Path, Handler, Opts})}
|
||||
|
@ -64,11 +65,13 @@ Code speaks more than words:
|
|||
cowboy_tcp_transport, [{port, 8080}],
|
||||
cowboy_http_protocol, [{dispatch, Dispatch}]
|
||||
).
|
||||
```
|
||||
|
||||
You must also write the `my_handler` module to process requests. You can
|
||||
use one of the predefined handlers or write your own. An hello world HTTP
|
||||
handler could be written like this:
|
||||
|
||||
``` erlang
|
||||
-module(my_handler).
|
||||
-export([init/3, handle/2, terminate/2]).
|
||||
|
||||
|
@ -81,3 +84,4 @@ handler could be written like this:
|
|||
|
||||
terminate(Req, State) ->
|
||||
ok.
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue