Browse files

Migrated to new cowboy, corrected and added specs.

  • Loading branch information...
1 parent 9eb6bc6 commit 5a251bd501c39bcfc390bceca7443d04c13ee0fc @Licenser Licenser committed Apr 14, 2013
View
3 Makefile
@@ -49,6 +49,9 @@ docs:
## Developer targets
##
+xref: compile
+ @$(REBAR) xref skip_deps=true
+
stage : rel
$(foreach dep,$(wildcard deps/* wildcard apps/*), rm -rf rel/wiggle/lib/$(shell basename $(dep))-* && ln -sf $(abspath $(dep)) rel/wiggle/lib;)
View
18 apps/wiggle/src/wiggle.app.src
@@ -6,16 +6,16 @@
{applications, [
kernel,
stdlib,
- libsnarl,
- libsniffle,
- libhowl,
- libchunter,
- jsx,
- lager,
- mimetypes,
- cowboy
+ libsnarl,
+ libsniffle,
+ libhowl,
+ libchunter,
+ jsx,
+ lager,
+ mimetypes,
+ cowboy
]},
{mod, { wiggle_app, []}},
{env, [{acceptors, 100},
- {port, 8080}]}
+ {port, 8080}]}
]}.
View
5 apps/wiggle/src/wiggle.erl
@@ -5,13 +5,18 @@
-ignore_xref([start/0]).
start() ->
+ lager:start(),
application:start(mdns_client_lib),
application:start(libsnarlmatch),
+ application:start(libchunter),
application:start(libsnarl),
+ application:start(libhowl),
application:start(libsniffle),
application:start(jsx),
application:start(lager),
application:start(mimetypes),
+ application:start(crypto),
+ application:start(ranch),
application:start(cowboy),
application:start(wiggle).
View
33 apps/wiggle/src/wiggle_app.erl
@@ -14,22 +14,23 @@ start(_StartType, _StartArgs) ->
{ok, Port} = application:get_env(wiggle, port),
{ok, Acceptors} = application:get_env(wiggle, acceptors),
- Dispatch = [{'_', [{[<<"api">>, '_', <<"users">>, '...'], wiggle_user_handler, []},
- {[<<"api">>, '_', <<"sessions">>, '...'], wiggle_session_handler, []},
- {[<<"api">>, '_', <<"groups">>, '...'], wiggle_group_handler, []},
- {[<<"api">>, '_', <<"cloud">>, '...'], wiggle_cloud_handler, []},
- {[<<"api">>, '_', <<"hypervisors">>, '...'], wiggle_hypervisor_handler, []},
- {[<<"api">>, '_', <<"dtrace">>, '_', <<"stream">>], wiggle_dtrace_stream, []},
- {[<<"api">>, '_', <<"dtrace">>, '...'], wiggle_dtrace_handler, []},
- {[<<"api">>, '_', <<"vms">>, '_', <<"console">>], wiggle_console_handler, []},
- {[<<"api">>, '_', <<"vms">>, '_', <<"vnc">>], wiggle_vnc_handler, []},
- {[<<"api">>, '_', <<"vms">>, '...'], wiggle_vm_handler, []},
- {[<<"api">>, '_', <<"ipranges">>, '...'], wiggle_iprange_handler, []},
- {[<<"api">>, '_', <<"datasets">>, '...'], wiggle_dataset_handler, []},
- {[<<"api">>, '_', <<"packages">>, '...'], wiggle_package_handler, []}]}],
- {ok, _} = cowboy:start_listener(http, Acceptors,
- cowboy_tcp_transport, [{port, Port}],
- cowboy_http_protocol, [{dispatch, Dispatch}]),
+ Dispatch = cowboy_router:compile(
+ [{'_', [{<<"/api/:version/users/[...]">>, wiggle_user_handler, []},
+ {<<"/api/:version/sessions/[...]">>, wiggle_session_handler, []},
+ {<<"/api/:version/groups/[...]">>, wiggle_group_handler, []},
+ {<<"/api/:version/cloud/[...]">>, wiggle_cloud_handler, []},
+ {<<"/api/:version/hypervisors/[...]">>, wiggle_hypervisor_handler, []},
+ {<<"/api/:version/dtrace/:uuid/stream">>, wiggle_dtrace_stream, []},
+ {<<"/api/:version/dtrace/[...]">>, wiggle_dtrace_handler, []},
+ {<<"/api/:version/vms/:uuid/console">>, wiggle_console_handler, []},
+ {<<"/api/:version/vms/:uuid/vnc">>, wiggle_vnc_handler, []},
+ {<<"/api/:version/vms/[...]">>, wiggle_vm_handler, []},
+ {<<"/api/:version/ipranges/[...]">>, wiggle_iprange_handler, []},
+ {<<"/api/:version/datasets/[...]">>, wiggle_dataset_handler, []},
+ {<<"/api/:version/packages/[...]">>, wiggle_package_handler, []}]}]
+ ),
+ {ok, _} = cowboy:start_http(http, Acceptors, [{port, Port}],
+ [{env, [{dispatch, Dispatch}]}]),
wiggle_sup:start_link().
View
18 apps/wiggle/src/wiggle_cloud_handler.erl
@@ -60,12 +60,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -142,19 +142,19 @@ handle_request(Req, State = #state{path = []}) ->
case libsniffle:cloud_status() of
{ok, {Metrics, Warnings}} ->
Vers0 = case libsnarl:version() of
- SrvVer when is_binary(SrvVer) ->
+ {ok, SrvVer} when is_binary(SrvVer) ->
[{snarl, SrvVer}];
_ ->
[{snarl, <<"not connected">>}]
end,
Vers1 = case libsniffle:version() of
- SrvVer1 when is_binary(SrvVer1) ->
+ {ok, SrvVer1} when is_binary(SrvVer1) ->
[{sniffle, SrvVer1} | Vers0];
_ ->
[{sniffle, <<"not connected">>} | Vers0]
end,
Vers2 = case libhowl:version() of
- SrvVer2 when is_binary(SrvVer2) ->
+ {ok, SrvVer2} when is_binary(SrvVer2) ->
[{howl, SrvVer2} | Vers1];
_ ->
[{howl, <<"not connected">>} | Vers1]
View
41 apps/wiggle/src/wiggle_console_handler.erl
@@ -1,47 +1,51 @@
-module(wiggle_console_handler).
--behaviour(cowboy_http_handler).
--behaviour(cowboy_http_websocket_handler).
+-behaviour(cowboy_websocket_handler).
-export([init/3,
handle/2,
terminate/2]).
+
-export([websocket_init/3,
websocket_handle/3,
websocket_info/3,
websocket_terminate/3]).
+-ignore_xref([init/3,
+ handle/2,
+ terminate/2]).
+
init({_Any, http}, Req, []) ->
- case cowboy_http_req:header('Upgrade', Req) of
+ case cowboy_req:header(<<"Upgrade">>, Req) of
{undefined, Req2} -> {ok, Req2, undefined};
{<<"websocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket};
{<<"WebSocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket}
end.
handle(Req, State) ->
- {ok, Req1} = cowboy_http_req:reply(200, [], <<"">>, Req),
+ {ok, Req1} = cowboy_req:reply(200, [], <<"">>, Req),
{ok, Req1, State}.
terminate(_Req, _State) ->
ok.
websocket_init(_Any, Req, []) ->
- {[<<"api">>, _, <<"vms">>, ID, <<"console">>], Req1} = cowboy_http_req:path(Req),
- {ok, Req2} = cowboy_http_req:set_resp_header(
+ {ID, Req1} = cowboy_req:binding(uuid, Req),
+ Req2 = cowboy_req:set_resp_header(
<<"Access-Control-Allow-Headers">>,
<<"X-Snarl-Token">>, Req1),
- {ok, Req3} = cowboy_http_req:set_resp_header(
+ Req3 = cowboy_req:set_resp_header(
<<"Access-Control-Expose-Headers">>,
<<"X-Snarl-Token">>, Req2),
- {ok, Req4} = cowboy_http_req:set_resp_header(
+ Req4 = cowboy_req:set_resp_header(
<<"Allow-Access-Control-Credentials">>,
<<"true">>, Req3),
- {Token, Req5} = case cowboy_http_req:header(<<"X-Snarl-Token">>, Req4) of
+ {Token, Req5} = case cowboy_req:header(<<"X-Snarl-Token">>, Req4) of
{undefined, ReqX} ->
- {TokenX, ReqX1} = cowboy_http_req:cookie(<<"X-Snarl-Token">>, ReqX),
+ {TokenX, ReqX1} = cowboy_req:cookie(<<"X-Snarl-Token">>, ReqX),
{TokenX, ReqX1};
{TokenX, ReqX} ->
- {ok, ReqX1} = cowboy_http_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
+ ReqX1 = cowboy_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
{TokenX, ReqX1}
end,
case libsnarl:allowed({token, Token}, [<<"vms">>, ID, <<"console">>]) of
@@ -52,28 +56,25 @@ websocket_init(_Any, Req, []) ->
{ok, HID} ->
case libsniffle:hypervisor_get(HID) of
{ok, H} ->
- HostBin = proplists:get_value(<<"host">>, H),
+ {ok,HostBin} = jsxd:get(<<"host">>, H),
Host = binary_to_list(HostBin),
- Port = proplists:get_value(<<"port">>, H),
+ {ok, Port} = jsxd:get(<<"port">>, H),
{ok, Console} = libchunter:console_open(Host, Port, ID, self()),
{ok, Req5, {Console}};
_ ->
- {ok, Req6} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- <<"could not find hypervisor">>, Req5),
+ {ok, Req6} = cowboy_req:reply(505, [], <<"could not find hypervisor">>, Req5),
{shutdown, Req6}
end;
_ ->
- {ok, Req6} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- <<"could not find hypervisor">>, Req5),
+ {ok, Req6} = cowboy_req:reply(505, [], <<"could not find hypervisor">>, Req5),
{shutdown, Req6}
end;
E ->
- {ok, Req6} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- list_to_binary(io_lib:format("~p", [E])), Req5),
+ {ok, Req6} = cowboy_req:reply(505, [], list_to_binary(io_lib:format("~p", [E])), Req5),
{shutdown, Req6}
end;
false ->
- {ok, Req6} = cowboy_http_req:reply(401, [{'Content-Type', <<"text/html">>}], <<"">>, Req5),
+ {ok, Req6} = cowboy_req:reply(401, Req5),
{shutdown, Req6}
end.
View
18 apps/wiggle/src/wiggle_dataset_handler.erl
@@ -59,12 +59,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
post_is_create(Req, State) ->
@@ -96,7 +96,7 @@ resource_exists(Req, State = #state{path = []}) ->
resource_exists(Req, State = #state{path = [Dataset | _]}) ->
case libsniffle:dataset_get(Dataset) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj = Obj}}
@@ -173,7 +173,7 @@ create_path(Req, State = #state{path = [], version = Version}) ->
{<<"/api/", Version/binary, "/datasets/", UUID/binary>>, Req1, State#state{body = Decoded}}.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
@@ -184,7 +184,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
View
20 apps/wiggle/src/wiggle_dtrace_handler.erl
@@ -63,12 +63,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -97,7 +97,7 @@ resource_exists(Req, State = #state{path = []}) ->
resource_exists(Req, State = #state{path = [Dtrace | _]}) ->
case libsniffle:dtrace_get(Dtrace) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj = Obj}}
@@ -185,12 +185,12 @@ create_path(Req, State = #state{path = [], version = Version}) ->
end,
{<<"/api/", Version/binary, "/dtrace/", UUID/binary>>, Req1, State#state{body = Data}};
duplicate ->
- {ok, Req3} = cowboy_http_req:reply(409, Req1),
+ {ok, Req3} = cowboy_req:reply(409, Req1),
{halt, Req3, State}
end.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, null);
@@ -201,7 +201,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, null);
View
92 apps/wiggle/src/wiggle_dtrace_stream.erl
@@ -1,18 +1,22 @@
-module(wiggle_dtrace_stream).
--behaviour(cowboy_http_handler).
--behaviour(cowboy_http_websocket_handler).
+-behaviour(cowboy_websocket_handler).
-export([init/3,
handle/2,
terminate/2]).
+
-export([websocket_init/3,
websocket_handle/3,
websocket_info/3,
websocket_terminate/3]).
+-ignore_xref([init/3,
+ handle/2,
+ terminate/2]).
+
init({_Any, http}, Req, []) ->
- case cowboy_http_req:header('Upgrade', Req) of
+ case cowboy_req:header(<<"Upgrade">>, Req) of
{undefined, Req2} -> {ok, Req2, undefined};
{<<"websocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket};
{<<"WebSocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket}
@@ -21,49 +25,49 @@ init({_Any, http}, Req, []) ->
-record(state, {id, socket, config, encoder, decoder, type}).
handle(Req, State) ->
- {ok, Req1} = cowboy_http_req:reply(200, [], <<"">>, Req),
+ {ok, Req1} = cowboy_req:reply(200, Req),
{ok, Req1, State}.
terminate(_Req, _State) ->
ok.
websocket_init(_Any, Req, []) ->
- {_, C, Req0} = cowboy_http_req:parse_header(<<"Sec-Websocket-Protocol">>, Req, <<"json">>),
- {[<<"api">>, _, <<"dtrace">>, ID, <<"stream">>], Req1} = cowboy_http_req:path(Req0),
- {ok, Req2} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Headers">>,
- <<"X-Snarl-Token">>, Req1),
- {ok, Req3} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Expose-Headers">>,
- <<"X-Snarl-Token">>, Req2),
- {ok, Req4} = cowboy_http_req:set_resp_header(
- <<"Allow-Access-Control-Credentials">>,
- <<"true">>, Req3),
+ {_, C, Req0} = cowboy_req:parse_header(<<"Sec-Websocket-Protocol">>, Req, <<"json">>),
+ {ID, Req1} = cowboy_req:binding(uuid, Req0),
+ Req2 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Headers">>,
+ <<"X-Snarl-Token">>, Req1),
+ Req3 = cowboy_req:set_resp_header(
+ <<"Access-Control-Expose-Headers">>,
+ <<"X-Snarl-Token">>, Req2),
+ Req4 = cowboy_req:set_resp_header(
+ <<"Allow-Access-Control-Credentials">>,
+ <<"true">>, Req3),
{Encoder, Decoder, Type} = case C of
- <<"msgpack">> ->
- {fun(O) ->
- msgpack:pack(O, [jsx])
- end,
- fun(D) ->
- {ok, O} = msgpack:unpack(D, [jsx]),
- jsxd:from_list(O)
- end,
- binary};
- <<"json">> ->
- {fun(O) ->
- jsx:encode(O)
- end,
- fun(D) ->
- jsxd:from_list(jsx:decode(D))
- end, text}
- end,
-
- {Token, Req5} = case cowboy_http_req:header(<<"X-Snarl-Token">>, Req4) of
+ <<"msgpack">> ->
+ {fun(O) ->
+ msgpack:pack(O, [jsx])
+ end,
+ fun(D) ->
+ {ok, O} = msgpack:unpack(D, [jsx]),
+ jsxd:from_list(O)
+ end,
+ binary};
+ <<"json">> ->
+ {fun(O) ->
+ jsx:encode(O)
+ end,
+ fun(D) ->
+ jsxd:from_list(jsx:decode(D))
+ end, text}
+ end,
+
+ {Token, Req5} = case cowboy_req:header(<<"X-Snarl-Token">>, Req4) of
{undefined, ReqX} ->
- {TokenX, ReqX1} = cowboy_http_req:cookie(<<"X-Snarl-Token">>, ReqX),
+ {TokenX, ReqX1} = cowboy_req:cookie(<<"X-Snarl-Token">>, ReqX),
{TokenX, ReqX1};
{TokenX, ReqX} ->
- {ok, ReqX1} = cowboy_http_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
+ ReqX1 = cowboy_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
{TokenX, ReqX1}
end,
case libsnarl:allowed({token, Token}, [<<"dtrace">>, ID, <<"stream">>]) of
@@ -73,18 +77,16 @@ websocket_init(_Any, Req, []) ->
{ok, Req, #state{id = ID, config = jsxd:get(<<"config">>, [], Obj),
encoder = Encoder, decoder = Decoder, type = Type}};
_ ->
- {ok, Req6} = cowboy_http_req:reply(404,
- [{'Content-Type', <<"text/html">>}],
- <<"not found">>, Req5),
+ {ok, Req6} = cowboy_req:reply(404, Req5),
{shutdown, Req6}
end;
false ->
- {ok, Req6} = cowboy_http_req:reply(401, [{'Content-Type', <<"text/html">>}], <<"">>, Req5),
+ {ok, Req6} = cowboy_req:reply(401, Req5),
{shutdown, Req6}
end.
websocket_handle({Type, <<>>}, Req, State = #state{type = Type}) ->
- handle(undefined, Req, State);
+ handle(null, Req, State);
websocket_handle({Type, M}, Req, State = #state{decoder = Dec, type = Type}) ->
handle(Dec(M), Req, State);
@@ -119,8 +121,7 @@ handle(null, Req, State = #state{encoder = Enc, type = Type}) ->
{reply, {Type, Enc([{<<"config">>, jsxd:merge([{<<"servers">>, Servers}], State#state.config)}])},
Req, State#state{socket = S}};
E ->
- {ok, Req1} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- list_to_binary(io_lib:format("~p", [E])), Req),
+ {ok, Req1} = cowboy_req:reply(505, [], list_to_binary(io_lib:format("~p", [E])), Req),
{shutdown, Req1}
end;
@@ -139,7 +140,7 @@ handle(Config, Req, State = #state{encoder = Enc, type = Type}) ->
{update, [<<"filter">>],
fun (F) ->
[{<<"and">>, [Filter | F]}]
- end, [{<<"and">>, Filter}]}], Config)
+ end, [{<<"and">>, Filter}]}], Config)
end,
Config2 = jsxd:update([<<"servers">>], fun(S) ->
S
@@ -150,7 +151,6 @@ handle(Config, Req, State = #state{encoder = Enc, type = Type}) ->
{reply, {Type, Enc(jsxd:merge(Config1, State#state.config))},
Req, State#state{socket = S}};
E ->
- {ok, Req1} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- list_to_binary(io_lib:format("~p", [E])), Req),
+ {ok, Req1} = cowboy_req:reply(505, [], list_to_binary(io_lib:format("~p", [E])), Req),
{shutdown, Req1}
end.
View
22 apps/wiggle/src/wiggle_group_handler.erl
@@ -50,7 +50,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"groups">>).
+ wiggle_handler:initial_state(Req).
post_is_create(Req, State) ->
{true, Req, State}.
@@ -64,12 +64,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
@@ -102,7 +102,7 @@ allowed_methods(_Version, _Token, [_Group, <<"permissions">> | _Permission]) ->
resource_exists(Req, State = #state{path = [Group, <<"permissions">> | Permission]}) ->
case {erlangify_permission(Permission), libsnarl:group_get(Group)} of
- {_, {ok, not_found}} ->
+ {_, not_found} ->
{false, Req, State};
{[], {ok, Obj}} ->
{true, Req, State#state{obj=Obj}};
@@ -115,7 +115,7 @@ resource_exists(Req, State = #state{path = []}) ->
resource_exists(Req, State = #state{path = [Group | _]}) ->
case libsnarl:group_get(Group) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj=Obj}}
@@ -217,7 +217,7 @@ create_path(Req, State = #state{path = [], version = Version}) ->
{<<"/api/", Version/binary, "/groups/", UUID/binary>>, Req1, State#state{body = Decoded}}.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
@@ -228,7 +228,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
View
42 apps/wiggle/src/wiggle_handler.erl
@@ -1,34 +1,35 @@
-module(wiggle_handler).
-export([
- initial_state/2,
+ initial_state/1,
accepted/0,
decode/1
]).
-record(state, {path, method, version, token, content, reply, obj, body}).
-initial_state(Req, Component) ->
- {Method, Req1} = cowboy_http_req:method(Req),
- {[<<"api">>, Version, Component | Path], Req2} = cowboy_http_req:path(Req1),
- {ok, Req3} = cowboy_http_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
- {Token, Req4} = case cowboy_http_req:header(<<"X-Snarl-Token">>, Req3) of
+initial_state(Req) ->
+ {Method, Req0} = cowboy_req:method(Req),
+ {Version, Req1} = cowboy_req:path_info(Req0),
+ {Path, Req2} = cowboy_req:path_info(Req1),
+ Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
+ {Token, Req4} = case cowboy_req:header(<<"X-Snarl-Token">>, Req3) of
{undefined, ReqX} ->
- {TokenX, ReqX1} = cowboy_http_req:cookie(<<"X-Snarl-Token">>, ReqX),
+ {TokenX, ReqX1} = cowboy_req:cookie(<<"X-Snarl-Token">>, ReqX),
{TokenX, ReqX1};
{TokenX, ReqX} ->
- {ok, ReqX1} = cowboy_http_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
+ ReqX1 = cowboy_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
{TokenX, ReqX1}
end,
- {ok, Req5} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Headers">>,
- <<"Content-Type, X-Snarl-Token">>, Req4),
- {ok, Req6} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Expose-Headers">>,
- <<"X-Snarl-Token">>, Req5),
- {ok, Req7} = cowboy_http_req:set_resp_header(
- <<"Allow-Access-Control-Credentials">>,
- <<"true">>, Req6),
+ Req5 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Headers">>,
+ <<"Content-Type, X-Snarl-Token">>, Req4),
+ Req6 = cowboy_req:set_resp_header(
+ <<"Access-Control-Expose-Headers">>,
+ <<"X-Snarl-Token">>, Req5),
+ Req7 = cowboy_req:set_resp_header(
+ <<"Allow-Access-Control-Credentials">>,
+ <<"true">>, Req6),
State = #state{version = Version,
method = Method,
token = Token,
@@ -51,9 +52,9 @@ accepted() ->
].
decode(Req) ->
- {{G, C, _}, Req0} = cowboy_http_req:parse_header('Content-Type', Req, {<<"application">>, <<"json">>, []}),
+ {ok, {G, C, _}, Req0} = cowboy_req:parse_header(<<"Content-Type">>, Req, {<<"application">>, <<"json">>, []}),
ContentType = <<G/binary, "/", C/binary>>,
- {ok, Body, Req1} = cowboy_http_req:body(Req0),
+ {ok, Body, Req1} = cowboy_req:body(Req0),
Decoded = case Body of
<<>> ->
[];
@@ -62,7 +63,8 @@ decode(Req) ->
{_, from_json} ->
jsxd:from_list(jsx:decode(Body));
{_, from_msgpack} ->
- jsxd:from_list(msgpack:unpack(Body, [jsx]))
+ {ok, D} = msgpack:unpack(Body, [jsx]),
+ jsxd:from_list(D)
end
end,
{ok, Decoded, Req1}.
View
20 apps/wiggle/src/wiggle_hypervisor_handler.erl
@@ -43,7 +43,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"hypervisors">>).
+ wiggle_handler:initial_state(Req).
service_available(Req, State) ->
case {libsniffle:servers(), libsnarl:servers()} of
@@ -56,12 +56,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -93,7 +93,7 @@ resource_exists(Req, State = #state{path = []}) ->
resource_exists(Req, State = #state{path = [Hypervisor | _]}) ->
case libsniffle:hypervisor_get(Hypervisor) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj = Obj}}
@@ -160,7 +160,7 @@ handle_request(Req, State = #state{path = [_Hypervisor], obj = Obj}) ->
%%--------------------------------------------------------------------
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
@@ -171,7 +171,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
View
23 apps/wiggle/src/wiggle_iprange_handler.erl
@@ -47,7 +47,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"ipranges">>).
+ wiggle_handler:initial_state(Req).
post_is_create(Req, State) ->
{true, Req, State}.
@@ -63,12 +63,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -189,13 +189,13 @@ create_path(Req, State = #state{path = [], version = Version}) ->
{ok, UUID} ->
{<<"/api/", Version/binary, "/ipranges/", UUID/binary>>, Req1, State#state{body = Data}};
duplicate ->
- {ok, Req2} = cowboy_http_req:reply(409, Req1),
+ {ok, Req2} = cowboy_req:reply(409, Req1),
{halt, Req2, State}
end.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
@@ -206,12 +206,13 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
_ ->
- Decoded = jsxd:from_list(msgpack:unpack(Body, [jsx])),
+ {ok, D} = msgpack:unpack(Body, [jsx]),
+ Decoded = jsxd:from_list(D),
handle_write(Req1, State, Decoded)
end,
{Reply, Req2, State1}.
View
22 apps/wiggle/src/wiggle_package_handler.erl
@@ -48,7 +48,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"packages">>).
+ wiggle_handler:initial_state(Req).
post_is_create(Req, State) ->
{true, Req, State}.
@@ -64,12 +64,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -98,7 +98,7 @@ resource_exists(Req, State = #state{path = []}) ->
resource_exists(Req, State = #state{path = [Package | _]}) ->
case libsniffle:package_get(Package) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj = Obj}}
@@ -177,12 +177,12 @@ create_path(Req, State = #state{path = [], version = Version}) ->
ok = libsniffle:package_set(UUID, Data1),
{<<"/api/", Version/binary, "/packages/", UUID/binary>>, Req1, State#state{body = Data1}};
duplicate ->
- {ok, Req2} = cowboy_http_req:reply(409, Req1),
+ {ok, Req2} = cowboy_req:reply(409, Req1),
{halt, Req2, State}
end.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, null);
@@ -193,7 +193,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, null);
View
26 apps/wiggle/src/wiggle_session_handler.erl
@@ -51,7 +51,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"sessions">>).
+ wiggle_handler:initial_state(Req).
post_is_create(Req, State) ->
{true, Req, State}.
@@ -67,12 +67,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'GET', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'GET', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -142,17 +142,17 @@ create_path(Req, State = #state{path = [], version = Version}) ->
{ok, Pass} = jsxd:get(<<"password">>, Decoded),
case libsnarl:auth(User, Pass) of
{ok, {token, UUID}} ->
- {ok, Req2} = cowboy_http_req:set_resp_cookie(<<"X-Snarl-Token">>, UUID,
- [{max_age, 364*24*60*60}], Req1),
- {ok, Req3} = cowboy_http_req:set_resp_header(<<"X-Snarl-Token">>, UUID, Req2),
+ Req2 = cowboy_req:set_resp_cookie(<<"X-Snarl-Token">>, UUID,
+ [{max_age, 364*24*60*60}], Req1),
+ Req3 = cowboy_req:set_resp_header(<<"X-Snarl-Token">>, UUID, Req2),
{<<"/api/", Version/binary, "/sessions/", UUID/binary>>, Req3, State#state{body = Decoded}};
_ ->
- {ok, Req2} = cowboy_http_req:reply(403, [], <<"Forbidden!">>, Req1),
+ {ok, Req2} = cowboy_req:reply(403, [], <<"Forbidden!">>, Req1),
{halt, Req2, State}
end.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
@@ -164,7 +164,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
{Reply, Req2, State1} = case Body of
<<>> ->
handle_write(Req1, State, []);
View
20 apps/wiggle/src/wiggle_user_handler.erl
@@ -53,7 +53,7 @@ init(_Transport, _Req, []) ->
{upgrade, protocol, cowboy_http_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"users">>).
+ wiggle_handler:initial_state(Req).
post_is_create(Req, State) ->
{true, Req, State}.
@@ -67,12 +67,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'GET', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'GET', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -263,7 +263,7 @@ create_path(Req, State = #state{path = [], version = Version}) ->
{<<"/api/", Version/binary, "/users/", UUID/binary>>, Req1, State#state{body = Decoded}}.
from_json(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
io:format("[PUT] ~p", [Body]),
{Reply, Req2, State1} = case Body of
<<>> ->
@@ -276,7 +276,7 @@ from_json(Req, State) ->
{Reply, Req2, State1}.
from_msgpack(Req, State) ->
- {ok, Body, Req1} = cowboy_http_req:body(Req),
+ {ok, Body, Req1} = cowboy_req:body(Req),
io:format("[PUT] ~p", [Body]),
{Reply, Req2, State1} = case Body of
<<>> ->
@@ -321,7 +321,7 @@ delete_resource(Req, State = #state{path = [User, <<"metadata">> | Path]}) ->
{true, Req, State};
delete_resource(Req, State = #state{path = [_User, <<"sessions">>]}) ->
- {ok, Req1} = cowboy_http_req:set_resp_cookie(<<"X-Snarl-Token">>, <<"">>, [{max_age, 0}], Req),
+ Req1 = cowboy_req:set_resp_cookie(<<"X-Snarl-Token">>, <<"">>, [{max_age, 0}], Req),
{true, Req1, State};
delete_resource(Req, State = #state{path = [User, <<"permissions">> | Permission]}) ->
View
25 apps/wiggle/src/wiggle_vm_handler.erl
@@ -1,6 +1,7 @@
%% Feel free to use, reuse and abuse the code in this file.
%% @doc Hello world handler.
+
-module(wiggle_vm_handler).
-export([init/3,
@@ -44,10 +45,10 @@
-record(state, {path, method, version, token, content, reply, obj, body}).
init(_Transport, _Req, []) ->
- {upgrade, protocol, cowboy_http_rest}.
+ {upgrade, protocol, cowboy_rest}.
rest_init(Req, _) ->
- wiggle_handler:initial_state(Req, <<"vms">>).
+ wiggle_handler:initial_state(Req).
service_available(Req, State) ->
case {libsniffle:servers(), libsnarl:servers()} of
@@ -60,12 +61,12 @@ service_available(Req, State) ->
end.
options(Req, State) ->
- Methods = allowed_methods(Req, State, State#state.path),
- {ok, Req1} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Methods">>,
- string:join(
- lists:map(fun erlang:atom_to_list/1,
- ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
+ Methods = allowed_methods(State#state.version, State#state.token, State#state.path),
+ Req1 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Methods">>,
+ string:join(
+ lists:map(fun erlang:atom_to_list/1,
+ ['HEAD', 'OPTIONS' | Methods]), ", "), Req),
{ok, Req1, State}.
content_types_provided(Req, State) ->
@@ -116,15 +117,15 @@ resource_exists(Req, State = #state{path = [Vm, <<"snapshots">>, Snap]}) ->
{false, Req, State};
{ok, Obj} ->
case jsxd:get([<<"snapshots">>, Snap], Obj) of
- not_found ->
+ undefined ->
{false, Req, State};
{ok, _} ->
{true, Req, State#state{obj=Obj}}
end
end;
resource_exists(Req, State = #state{path = [Vm | _]}) ->
case libsniffle:vm_get(Vm) of
- {ok, not_found} ->
+ not_found ->
{false, Req, State};
{ok, Obj} ->
{true, Req, State#state{obj=Obj}}
@@ -251,13 +252,13 @@ create_path(Req, State = #state{path = [], version = Version, token = Token}) ->
catch
G:E ->
lager:error("Error creating VM(~p): ~p / ~p", [Decoded, G, E]),
- {ok, Req2} = cowboy_http_req:reply(500, Req1),
+ {ok, Req2} = cowboy_req:reply(500, Req1),
{halt, Req2, State}
end
catch
G1:E1 ->
lager:error("Error creating VM(~p): ~p / ~p", [Decoded, G1, E1]),
- {ok, Req3} = cowboy_http_req:reply(400, Req1),
+ {ok, Req3} = cowboy_req:reply(400, Req1),
{halt, Req3, State}
end;
View
50 apps/wiggle/src/wiggle_vnc_handler.erl
@@ -1,48 +1,52 @@
-module(wiggle_vnc_handler).
--behaviour(cowboy_http_handler).
--behaviour(cowboy_http_websocket_handler).
+-behaviour(cowboy_websocket_handler).
-export([init/3,
handle/2,
terminate/2]).
+
-export([websocket_init/3,
websocket_handle/3,
websocket_info/3,
websocket_terminate/3]).
+-ignore_xref([init/3,
+ handle/2,
+ terminate/2]).
+
init({_Any, http}, Req, []) ->
- case cowboy_http_req:header('Upgrade', Req) of
+ case cowboy_req:header(<<"Upgrade">>, Req) of
{undefined, Req2} -> {ok, Req2, undefined};
{<<"websocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket};
{<<"WebSocket">>, _Req2} -> {upgrade, protocol, cowboy_http_websocket}
end.
handle(Req, State) ->
io:format("~p~n", [Req]),
- {ok, Req1} = cowboy_http_req:reply(200, [], <<"">>, Req),
+ {ok, Req1} = cowboy_req:reply(200, [], <<"">>, Req),
{ok, Req1, State}.
terminate(_Req, _State) ->
ok.
websocket_init(_Any, Req, []) ->
- {[<<"api">>, _, <<"vms">>, ID, <<"vnc">>], Req1} = cowboy_http_req:path(Req),
- {ok, Req2} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Allow-Headers">>,
- <<"X-Snarl-Token">>, Req1),
- {ok, Req3} = cowboy_http_req:set_resp_header(
- <<"Access-Control-Expose-Headers">>,
- <<"X-Snarl-Token">>, Req2),
- {ok, Req4} = cowboy_http_req:set_resp_header(
- <<"Allow-Access-Control-Credentials">>,
- <<"true">>, Req3),
- {Token, Req5} = case cowboy_http_req:header(<<"X-Snarl-Token">>, Req4) of
+ {ID, Req1} = cowboy_req:binding(uuid, Req),
+ Req2 = cowboy_req:set_resp_header(
+ <<"Access-Control-Allow-Headers">>,
+ <<"X-Snarl-Token">>, Req1),
+ Req3 = cowboy_req:set_resp_header(
+ <<"Access-Control-Expose-Headers">>,
+ <<"X-Snarl-Token">>, Req2),
+ Req4 = cowboy_req:set_resp_header(
+ <<"Allow-Access-Control-Credentials">>,
+ <<"true">>, Req3),
+ {Token, Req5} = case cowboy_req:header(<<"X-Snarl-Token">>, Req4) of
{undefined, ReqX} ->
- {TokenX, ReqX1} = cowboy_http_req:cookie(<<"X-Snarl-Token">>, ReqX),
+ {TokenX, ReqX1} = cowboy_req:cookie(<<"X-Snarl-Token">>, ReqX),
{TokenX, ReqX1};
{TokenX, ReqX} ->
- {ok, ReqX1} = cowboy_http_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
+ ReqX1 = cowboy_req:set_resp_header(<<"X-Snarl-Token">>, TokenX, ReqX),
{TokenX, ReqX1}
end,
case libsnarl:allowed({token, Token}, [<<"vms">>, ID, <<"console">>]) of
@@ -57,24 +61,22 @@ websocket_init(_Any, Req, []) ->
[binary,{nodelay, true}, {packet, 0}]) of
{ok, Socket} ->
gen_tcp:controlling_process(Socket, self()),
- Req6 = cowboy_http_req:compact(Req5),
+ Req6 = cowboy_req:compact(Req5),
{ok, Req6, {Socket}, hibernate};
_ ->
- Req6 = cowboy_http_req:compact(Req5),
+ Req6 = cowboy_req:compact(Req5),
{ok, Req6, undefined, hibernate}
end;
_ ->
- {ok, Req6} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- <<"could not find vnc">>, Req5),
+ {ok, Req6} = cowboy_req:reply(505, [], <<"could not find vnc">>, Req5),
{shutdown, Req6}
end;
E ->
- {ok, Req6} = cowboy_http_req:reply(505, [{'Content-Type', <<"text/html">>}],
- list_to_binary(io_lib:format("~p", [E])), Req5),
+ {ok, Req6} = cowboy_req:reply(505, [], list_to_binary(io_lib:format("~p", [E])), Req5),
{shutdown, Req6}
end;
false ->
- {ok, Req6} = cowboy_http_req:reply(401, [{'Content-Type', <<"text/html">>}], <<"">>, Req5),
+ {ok, Req6} = cowboy_req:reply(401, Req5),
{shutdown, Req6}
end.
View
42 dialyzer.mittigate
@@ -1,38 +1,6 @@
-^leexinc.hrl:49:
-^leexinc.hrl:52:
-^leexinc.hrl:54:
-^leexinc.hrl:59:
-^leexinc.hrl:62:
-^leexinc.hrl:118:
-^leexinc.hrl:121:
-^leexinc.hrl:123:
-^leexinc.hrl:128:
-^leexinc.hrl:131:
-^leexinc.hrl:192:
-^leexinc.hrl:195:
-^leexinc.hrl:197:
-^leexinc.hrl:202:
-^leexinc.hrl:205:
-^leexinc.hrl:243:
-^leexinc.hrl:246:
-^leexinc.hrl:248:
-^leexinc.hrl:253:
-^leexinc.hrl:256:
-^leexinc.hrl:260:
-^cowboy_http_protocol.erl:36:
-^jsx_parser.erl:64:
+^msgpack_
+^leexinc
+^jsx_
^jsx_parser.erl:65:
-^lager_stdlib.erl:453:
-^lager_stdlib.erl:502:
-^lager_trunc_io.erl:74:
-^lager_trunc_io.erl:98:
-^mdns_discovery_connect_node_handler.erl:30:
-^mimetypes.erl:337:
-^mimetypes.erl:344:
-^mimetypes.erl:355:
-^mimetypes.erl:363:
-^mimetypes.erl:542:
-^mimetypes.erl:549:
-^mimetypes.erl:569:
-^mimetypes.erl:577:
-^mimetypes_parse.erl:214:
+^lager_
+^mimetypes
View
4 rebar.config
@@ -6,10 +6,10 @@
{edoc_opts, [{dir, "../../doc"}]}.
{deps,
[
- {lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "1.0.0"}}},
+ {lager, ".*", {git, "git://github.com/basho/lager.git", {tag, "1.2.1"}}},
{jsx, ".*", {git, "http://github.com/talentdeficit/jsx.git", {tag, "v1.3.3"}}},
{mimetypes, ".*", {git, "http://github.com/spawngrid/mimetypes.git", {branch, master}}},
- {cowboy, ".*", {git, "https://github.com/extend/cowboy.git", {tag, "0.6.1"}}},
+ {cowboy, ".*", {git, "https://github.com/extend/cowboy.git", {tag, "0.8.3"}}},
{msgpack, ".*", {git, "git://github.com/msgpack/msgpack-erlang.git", {tag, "0.1.2"}}},
{jsxd, ".*", {git, "https://github.com/Licenser/jsxd.git", {branch, master}}},
{libhowl, ".*", {git, "http://github.com/project-fifo/libhowl.git", {branch, test}}},

0 comments on commit 5a251bd

Please sign in to comment.