Skip to content

Commit 45edb6e

Browse files
authored
Fix compatibility with ranch 2.x (#64)
Ranch 2.x changes the return value from :ranch.child_spec/5 to be a map.
1 parent f82f2ff commit 45edb6e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/plug/cowboy.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,13 @@ defmodule Plug.Cowboy do
231231
{:ranch_ssl, :cowboy_tls, %{transport_opts | socket_opts: socket_opts}}
232232
end
233233

234-
{id, start, restart, shutdown, type, modules} =
235-
:ranch.child_spec(ref, ranch_module, transport_opts, cowboy_protocol, proto_opts)
234+
case :ranch.child_spec(ref, ranch_module, transport_opts, cowboy_protocol, proto_opts) do
235+
{id, start, restart, shutdown, type, modules} ->
236+
%{id: id, start: start, restart: restart, shutdown: shutdown, type: type, modules: modules}
236237

237-
%{id: id, start: start, restart: restart, shutdown: shutdown, type: type, modules: modules}
238+
child_spec when is_map(child_spec) ->
239+
child_spec
240+
end
238241
end
239242

240243
## Helpers

0 commit comments

Comments
 (0)