Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dependencies #111

Merged
merged 2 commits into from
May 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions example/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
, strict_validation
, warn_export_vars
, warn_exported_vars
, warn_missing_spec
, warn_untyped_record
, debug_info]}.

%% == Dependencies ==

{deps, [ {mixer, "0.1.5", {pkg, inaka_mixer}}
{deps, [ {mixer, "1.0.0", {pkg, inaka_mixer}}
, cowboy_swagger
]}.

Expand Down
20 changes: 10 additions & 10 deletions example/rebar.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{"1.1.0",
[{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.1.0">>},2},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.0.1">>},3},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.8.1">>},1},
{<<"mixer">>,{pkg,<<"inaka_mixer">>,<<"0.1.5">>},0},
[{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.3.0">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.2.1">>},2},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.9.0">>},1},
{<<"mixer">>,{pkg,<<"inaka_mixer">>,<<"1.0.0">>},0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.4.0">>},2},
{<<"trails">>,{pkg,<<"trails">>,<<"2.0.0">>},1}]}.
{<<"trails">>,{pkg,<<"trails">>,<<"2.1.0">>},1}]}.
[
{pkg_hash,[
{<<"cowboy">>, <<"69F9DB3B23C24AB6B3A169A6357130C16B39CDA1A1F8C582F818883EE552589D">>},
{<<"cowlib">>, <<"4DFFFB1DB296EAB9F2E8B95EE3017007F674BC920CE30AEB5A53BBDA82FC38C0">>},
{<<"jsx">>, <<"1453B4EB3615ACB3E2CD0A105D27E6761E2ED2E501AC0B390F5BBEC497669846">>},
{<<"mixer">>, <<"754630C0E60221B23E4D83ADF6E789A8B283855E23F9391EEC40980E6E800486">>},
{<<"cowboy">>, <<"268429481D6F41AD5564ADE4A2439C284B569083FCA0D19078AD4F56B4624724">>},
{<<"cowlib">>, <<"1AFA5B233CEE8F642C153EC6F1DC48DB0DD9A43E2114BC8B43E9D59636F6AE1F">>},
{<<"jsx">>, <<"D2F6E5F069C00266CAD52FB15D87C428579EA4D7D73A33669E12679E203329DD">>},
{<<"mixer">>, <<"B991687E1D7750CAB5906800F9F451E96594F77F8F0FFA304602DF92E7A58607">>},
{<<"ranch">>, <<"10272F95DA79340FA7E8774BA7930B901713D272905D0012B06CA6D994F8826B">>},
{<<"trails">>, <<"40125994045FBDB07909D0778E12004B3B7722E25AAE292EC83019630BA66E7E">>}]}
{<<"trails">>, <<"D51D7F065F2B692654C611C663BFAC377D47EAFF9D38D0C17ECD031D1A59399A">>}]}
].
8 changes: 5 additions & 3 deletions example/src/example_default.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
-module(example_default).

-export([ init/3
-behaviour(cowboy_rest).

-export([ init/2
, rest_init/2
, content_types_accepted/2
, content_types_provided/2
Expand All @@ -9,8 +11,8 @@
]).

%% cowboy
init(_Transport, _Req, _Opts) ->
{upgrade, protocol, cowboy_rest}.
init(Req, _Opts) ->
{cowboy_rest, Req, #{}}.

rest_init(Req, _Opts) ->
{ok, Req, #{}}.
Expand Down
4 changes: 3 additions & 1 deletion example/src/example_description_handler.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
-module(example_description_handler).

-behaviour(cowboy_rest).

-include_lib("mixer/include/mixer.hrl").
-mixin([
{example_default,
[
init/3,
init/2,
rest_init/2,
content_types_accepted/2,
content_types_provided/2,
Expand Down
10 changes: 6 additions & 4 deletions example/src/example_echo_handler.erl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
-module(example_echo_handler).

-behaviour(cowboy_rest).

-include_lib("mixer/include/mixer.hrl").
-mixin([
{example_default,
[
init/3,
init/2,
rest_init/2,
content_types_accepted/2,
content_types_provided/2,
Expand Down Expand Up @@ -54,8 +56,8 @@ handle_get(Req, State) ->
{Body, Req, State}.

handle_put(Req, State) ->
{Echo, Req1} = cowboy_req:binding(echo, Req, ""),
Echo = cowboy_req:binding(echo, Req, ""),
application:set_env(example, echo, Echo),
Body = [<<"You put an echo! ">> , Echo],
Req2 = cowboy_req:set_resp_body(Body, Req1),
{true, Req2, State}.
Req1 = cowboy_req:set_resp_body(Body, Req),
{true, Req1, State}.
15 changes: 9 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

{profiles, [
{test, [
{deps, [ {katana_test, "0.1.1"}
, {mixer, "0.1.5", {pkg, inaka_mixer}}
{deps, [ {katana_test, "1.0.0"}
, {mixer, "1.0.0", {pkg, inaka_mixer}}
, {shotgun, "0.3.0"}
]}
]}
Expand Down Expand Up @@ -60,20 +60,23 @@

%% == Dependencies ==

{deps, [ {jsx, "2.8.1"}
, {trails, "2.0.0"}
{deps, [ {jsx, "2.9.0"}
, {cowboy, "2.3.0"}
, {ranch, "1.4.0"}
, {trails, "2.1.0"}
]}.

%% == Dialyzer ==

{dialyzer, [ {warnings, [ no_return
, unmatched_returns
, error_handling
, unknown
]}
, {plt_apps, top_level_deps}
, {plt_extra_apps, []}
, {plt_extra_apps, [cowboy, trails, ranch, jsx]}
, {plt_location, local}
, {base_plt_apps, [stdlib, kernel]}
, {base_plt_apps, [stdlib, kernel, erts]}
, {base_plt_location, global}]}.


Expand Down
16 changes: 8 additions & 8 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{"1.1.0",
[{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.1.0">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.0.1">>},2},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.8.1">>},0},
[{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.3.0">>},0},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.2.1">>},1},
{<<"jsx">>,{pkg,<<"jsx">>,<<"2.9.0">>},0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.4.0">>},1},
{<<"trails">>,{pkg,<<"trails">>,<<"2.0.0">>},0}]}.
{<<"trails">>,{pkg,<<"trails">>,<<"2.1.0">>},0}]}.
[
{pkg_hash,[
{<<"cowboy">>, <<"69F9DB3B23C24AB6B3A169A6357130C16B39CDA1A1F8C582F818883EE552589D">>},
{<<"cowlib">>, <<"4DFFFB1DB296EAB9F2E8B95EE3017007F674BC920CE30AEB5A53BBDA82FC38C0">>},
{<<"jsx">>, <<"1453B4EB3615ACB3E2CD0A105D27E6761E2ED2E501AC0B390F5BBEC497669846">>},
{<<"cowboy">>, <<"268429481D6F41AD5564ADE4A2439C284B569083FCA0D19078AD4F56B4624724">>},
{<<"cowlib">>, <<"1AFA5B233CEE8F642C153EC6F1DC48DB0DD9A43E2114BC8B43E9D59636F6AE1F">>},
{<<"jsx">>, <<"D2F6E5F069C00266CAD52FB15D87C428579EA4D7D73A33669E12679E203329DD">>},
{<<"ranch">>, <<"10272F95DA79340FA7E8774BA7930B901713D272905D0012B06CA6D994F8826B">>},
{<<"trails">>, <<"40125994045FBDB07909D0778E12004B3B7722E25AAE292EC83019630BA66E7E">>}]}
{<<"trails">>, <<"D51D7F065F2B692654C611C663BFAC377D47EAFF9D38D0C17ECD031D1A59399A">>}]}
].
2 changes: 2 additions & 0 deletions src/cowboy_swagger.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
{applications,
[kernel,
stdlib,
ranch,
cowboy,
trails,
jsx
]},
Expand Down
6 changes: 3 additions & 3 deletions src/cowboy_swagger_handler.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%% @doc Cowboy Swagger Handler. This handler exposes a GET operation
%%% to enable that `swagger.json' can be retrieved from embedded
%%% to enable `swagger.json' to be retrieved from embedded
%%% Swagger-UI (located in `priv/swagger' folder).
-module(cowboy_swagger_handler).

Expand All @@ -8,7 +8,7 @@
-export([trails/0, trails/1]).

-type route_match() :: '_' | iodata().
-type options() :: #{server => ranch:ref(), host => route_match()}.
-export_type([route_match/0]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Trails
Expand All @@ -20,7 +20,7 @@
%% that returns the `swagger.json'.
-spec trails() -> trails:trails().
trails() -> trails(#{}).
-spec trails(Options::options()) -> trails:trails().
-spec trails(cowboy_swagger_json_handler:options()) -> trails:trails().
trails(Options) ->
StaticFiles =
case application:get_env(cowboy_swagger, static_files) of
Expand Down
19 changes: 14 additions & 5 deletions src/cowboy_swagger_json_handler.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%% @doc Cowboy Swagger Handler. This handler exposes a GET operation
%%% to enable that `swagger.json' can be retrieved from embedded
%%% to enable `swagger.json' to be retrieved from embedded
%%% Swagger-UI (located in `priv/swagger' folder).
-module(cowboy_swagger_json_handler).

Expand All @@ -8,24 +8,33 @@
, content_types_provided/2
]).

-behaviour(cowboy_rest).

%% Handlers
-export([handle_get/2]).

-type state() :: #{}.
-type options() :: #{ server => ranch:ref()
, host => cowboy_swagger_handler:route_match()
, _ => _
}.
-export_type([options/0]).

-type state() :: options().

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Cowboy Callbacks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% @hidden
-spec init(cowboy_req:req(), state()) ->
-spec init(cowboy_req:req(), options()) ->
{cowboy_rest, cowboy_req:req(), state()}.
init(Req, State) ->
init(Req, Opts) ->
State = Opts,
{cowboy_rest, Req, State}.

%% @hidden
-spec content_types_provided(cowboy_req:req(), state()) ->
{[term()], cowboy_req:req(), state()}.
{[{binary(), atom()}], cowboy_req:req(), state()}.
content_types_provided(Req, State) ->
{[{<<"application/json">>, handle_get}], Req, State}.

Expand Down
4 changes: 3 additions & 1 deletion src/cowboy_swagger_redirect_handler.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-module(cowboy_swagger_redirect_handler).

-behaviour(cowboy_rest).

%% Cowboy callbacks
-export([init/2]).

Expand Down Expand Up @@ -35,6 +37,6 @@ previously_existed(Req, State) ->

%% @hidden
-spec moved_permanently(Req::cowboy_req:req(), State::state()) ->
{{boolean(), string()}, cowboy_req:req(), state()}.
{{true, iodata()}, cowboy_req:req(), state()}.
moved_permanently(Req, State) ->
{{true, "/api-docs/index.html"}, Req, State}.
7 changes: 6 additions & 1 deletion test/cowboy_swagger_meta_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

-spec init_per_suite(config()) -> config().
init_per_suite(Config) ->
[ {application, cowboy_swagger} | Config].
[ {application, cowboy_swagger}
%% Until the next version of katana-test fixes the missing test deps in plt
%% issue, we can't use the default warnings that include 'unknown' here.
, {dialyzer_warnings, [error_handling, race_conditions, unmatched_returns]}
| Config
].

-spec end_per_suite(config()) -> config().
end_per_suite(Config) -> Config.
4 changes: 2 additions & 2 deletions test/host1_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ allowed_methods(Req, State) ->

%% internal
handle_get(Req, State) ->
{Host, Req1} = cowboy_req:host(Req),
Host = cowboy_req:host(Req),
Body = <<"I am ", Host/binary>>,
{Body, Req1, State}.
{Body, Req, State}.