diff --git a/doc/src/guide/constraints.asciidoc b/doc/src/guide/constraints.asciidoc index 822962d2..7721831e 100644 --- a/doc/src/guide/constraints.asciidoc +++ b/doc/src/guide/constraints.asciidoc @@ -74,11 +74,11 @@ to an integer: [source,erlang] ---- fun (Value0) when is_binary(Value0) -> - try binary_to_integer(Value0) of - Value -> {true, Value} - catch _:_ -> - false - end. + try binary_to_integer(Value0) of + Value -> {true, Value} + catch _:_ -> + false + end. ---- Constraint functions should only crash because the programmer diff --git a/doc/src/guide/cookies.asciidoc b/doc/src/guide/cookies.asciidoc index 58bd1d10..33a19404 100644 --- a/doc/src/guide/cookies.asciidoc +++ b/doc/src/guide/cookies.asciidoc @@ -50,7 +50,7 @@ They can also be set for a duration in seconds: ---- SessionID = generate_session_id(), Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, - #{max_age => 3600}, Req0). + #{max_age => 3600}, Req0). ---- To delete cookies, set `max_age` to 0: @@ -59,7 +59,7 @@ To delete cookies, set `max_age` to 0: ---- SessionID = generate_session_id(), Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, - #{max_age => 0}, Req0). + #{max_age => 0}, Req0). ---- To restrict cookies to a specific domain and path, the options @@ -68,7 +68,7 @@ of the same name can be used: [source,erlang] ---- Req = cowboy_req:set_resp_cookie(<<"inaccount">>, <<"1">>, - #{domain => "my.example.org", path => "/account"}, Req0). + #{domain => "my.example.org", path => "/account"}, Req0). ---- Cookies will be sent with requests to this domain and all @@ -82,7 +82,7 @@ available over HTTPS): ---- SessionID = generate_session_id(), Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, - #{secure => true}, Req0). + #{secure => true}, Req0). ---- To prevent client-side scripts from accessing a cookie: @@ -91,7 +91,7 @@ To prevent client-side scripts from accessing a cookie: ---- SessionID = generate_session_id(), Req = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, - #{http_only => true}, Req0). + #{http_only => true}, Req0). ---- Cookies may also be set client-side, for example using diff --git a/doc/src/guide/getting_started.asciidoc b/doc/src/guide/getting_started.asciidoc index be11e489..74164be5 100644 --- a/doc/src/guide/getting_started.asciidoc +++ b/doc/src/guide/getting_started.asciidoc @@ -91,14 +91,14 @@ code to the `start/2` function to make it look like this: [source,erlang] ---- start(_Type, _Args) -> - Dispatch = cowboy_router:compile([ - {'_', [{"/", hello_handler, []}]} - ]), - {ok, _} = cowboy:start_clear(my_http_listener, 100, - [{port, 8080}], - #{env => #{dispatch => Dispatch}} - ), - hello_erlang_sup:start_link(). + Dispatch = cowboy_router:compile([ + {'_', [{"/", hello_handler, []}]} + ]), + {ok, _} = cowboy:start_clear(my_http_listener, 100, + [{port, 8080}], + #{env => #{dispatch => Dispatch}} + ), + hello_erlang_sup:start_link(). ---- Routes are explained in details in the xref:routing[Routing] @@ -127,11 +127,11 @@ the `init/2` function like this to send a reply. [source,erlang] ---- init(Req0, State) -> - Req = cowboy_req:reply(200, - #{<<"content-type">> => <<"text/plain">>}, - <<"Hello Erlang!">>, - Req0), - {ok, Req, State}. + Req = cowboy_req:reply(200, + #{<<"content-type">> => <<"text/plain">>}, + <<"Hello Erlang!">>, + Req0), + {ok, Req, State}. ---- What the above code does is send a `200 OK` reply, with the diff --git a/doc/src/guide/handlers.asciidoc b/doc/src/guide/handlers.asciidoc index a59b8cf6..88fbc21f 100644 --- a/doc/src/guide/handlers.asciidoc +++ b/doc/src/guide/handlers.asciidoc @@ -65,7 +65,7 @@ following snippet switches to a Websocket handler: [source,erlang] ---- init(Req, State) -> - {cowboy_websocket, Req, State}. + {cowboy_websocket, Req, State}. ---- You can also switch to your own custom handler type: @@ -73,7 +73,7 @@ You can also switch to your own custom handler type: [source,erlang] ---- init(Req, State) -> - {my_handler_type, Req, State}. + {my_handler_type, Req, State}. ---- How to implement a custom handler type is described in the diff --git a/doc/src/guide/listeners.asciidoc b/doc/src/guide/listeners.asciidoc index 577883be..901b9220 100644 --- a/doc/src/guide/listeners.asciidoc +++ b/doc/src/guide/listeners.asciidoc @@ -28,14 +28,14 @@ on port 8080: [source,erlang] ---- start(_Type, _Args) -> - Dispatch = cowboy_router:compile([ - {'_', [{"/", hello_handler, []}]} - ]), - {ok, _} = cowboy:start_clear(my_http_listener, 100, - [{port, 8080}], - #{env => #{dispatch => Dispatch}} - ), - hello_erlang_sup:start_link(). + Dispatch = cowboy_router:compile([ + {'_', [{"/", hello_handler, []}]} + ]), + {ok, _} = cowboy:start_clear(my_http_listener, 100, + [{port, 8080}], + #{env => #{dispatch => Dispatch}} + ), + hello_erlang_sup:start_link(). ---- The xref:getting_started[Getting Started] chapter uses a @@ -72,18 +72,18 @@ used directly to setup a custom listener. [source,erlang] ---- start(_Type, _Args) -> - Dispatch = cowboy_router:compile([ - {'_', [{"/", hello_handler, []}]} - ]), - {ok, _} = cowboy:start_tls(my_http_listener, 100, - [ - {port, 8443}, - {certfile, "/path/to/certfile"}, - {keyfile, "/path/to/keyfile"} - ], - #{env => #{dispatch => Dispatch}} - ), - hello_erlang_sup:start_link(). + Dispatch = cowboy_router:compile([ + {'_', [{"/", hello_handler, []}]} + ]), + {ok, _} = cowboy:start_tls(my_http_listener, 100, + [ + {port, 8443}, + {certfile, "/path/to/certfile"}, + {keyfile, "/path/to/keyfile"} + ], + #{env => #{dispatch => Dispatch}} + ), + hello_erlang_sup:start_link(). ---- Clients connecting to Cowboy on the secure listener are diff --git a/doc/src/guide/req.asciidoc b/doc/src/guide/req.asciidoc index 5bd6701c..9afee098 100644 --- a/doc/src/guide/req.asciidoc +++ b/doc/src/guide/req.asciidoc @@ -32,15 +32,15 @@ otherwise. [source,erlang] ---- init(Req0=#{method := <<"GET">>}, State) -> - Req = cowboy_req:reply(200, #{ - <<"content-type">> => <<"text/plain">> - }, <<"Hello world!">>, Req0), - {ok, Req, State}; + Req = cowboy_req:reply(200, #{ + <<"content-type">> => <<"text/plain">> + }, <<"Hello world!">>, Req0), + {ok, Req, State}; init(Req0, State) -> - Req = cowboy_req:reply(405, #{ - <<"allow">> => <<"GET">> - }, Req0), - {ok, Req, State}. + Req = cowboy_req:reply(405, #{ + <<"allow">> => <<"GET">> + }, Req0), + {ok, Req, State}. ---- Any other field is internal and should not be accessed. @@ -135,11 +135,11 @@ of the effective request URI can all be retrieved directly: [source,erlang] ---- #{ - scheme := Scheme, - host := Host, - port := Port, - path := Path, - qs := Qs + scheme := Scheme, + host := Host, + port := Port, + path := Path, + qs := Qs } = Req. ---- @@ -348,7 +348,7 @@ directly: [source,erlang] ---- ParsedVal = cowboy_req:parse_header(<<"content-type">>, Req, - {<<"text">>, <<"plain">>, []}). + {<<"text">>, <<"plain">>, []}). ---- === Peer diff --git a/doc/src/guide/req_body.asciidoc b/doc/src/guide/req_body.asciidoc index 0b8c1dd0..4906811e 100644 --- a/doc/src/guide/req_body.asciidoc +++ b/doc/src/guide/req_body.asciidoc @@ -71,7 +71,7 @@ only up to 1MB for up to 5 seconds: [source,erlang] ---- {ok, Data, Req} = cowboy_req:read_body(Req0, - #{length => 1000000, period => 5000}). + #{length => 1000000, period => 5000}). ---- You may also disable the length limit: @@ -126,5 +126,5 @@ read for up to 64KB and up to 5 seconds. They can be modified: [source,erlang] ---- {ok, KeyValues, Req} = cowboy_req:read_urlencoded_body(Req0, - #{length => 4096, period => 3000}). + #{length => 4096, period => 3000}). ---- diff --git a/doc/src/guide/resp.asciidoc b/doc/src/guide/resp.asciidoc index b8ba7d5a..1f6b3188 100644 --- a/doc/src/guide/resp.asciidoc +++ b/doc/src/guide/resp.asciidoc @@ -71,7 +71,7 @@ Body = <<"Hats off!">>, Req = cowboy_req:reply(200, #{ <<"content-type">> => <<"text/html">> }, ["
", Body, "
"], Req0). + "", Body, "