mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Add optional automatic response body compression
This behavior can be enabled with the `compress` protocol option. See the `compress_response` example for more details. All tests are now ran with and without compression for both HTTP and HTTPS.
This commit is contained in:
parent
a013becc66
commit
01f57ad65d
13 changed files with 294 additions and 23 deletions
26
examples/compress_response/src/compress_response_app.erl
Normal file
26
examples/compress_response/src/compress_response_app.erl
Normal file
|
@ -0,0 +1,26 @@
|
|||
%% Feel free to use, reuse and abuse the code in this file.
|
||||
|
||||
%% @private
|
||||
-module(compress_response_app).
|
||||
-behaviour(application).
|
||||
|
||||
%% API.
|
||||
-export([start/2]).
|
||||
-export([stop/1]).
|
||||
|
||||
%% API.
|
||||
|
||||
start(_Type, _Args) ->
|
||||
Dispatch = [
|
||||
{'_', [
|
||||
{[], toppage_handler, []}
|
||||
]}
|
||||
],
|
||||
{ok, _} = cowboy:start_http(http, 100, [{port, 8080}], [
|
||||
{compress, true},
|
||||
{env, [{dispatch, Dispatch}]}
|
||||
]),
|
||||
compress_response_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
ok.
|
Loading…
Add table
Add a link
Reference in a new issue