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 to plug v1.7 #116

Merged
merged 1 commit into from Dec 2, 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
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,3 @@
/_build
/docs
/doc
mix.lock
7 changes: 2 additions & 5 deletions .travis.yml
Expand Up @@ -2,9 +2,6 @@ language: elixir

matrix:
include:
- otp_release: 19.3
elixir: 1.3.4

- otp_release: 19.3
elixir: 1.4.5
- otp_release: 20.3
Expand All @@ -20,8 +17,8 @@ matrix:
- otp_release: 20.3
elixir: 1.6.6

- otp_release: 21.0
elixir: 1.7.2
- otp_release: 21.1
elixir: 1.7.4

sudo: false
notifications:
Expand Down
4 changes: 1 addition & 3 deletions lib/maru.ex
Expand Up @@ -35,9 +35,7 @@ defmodule Maru do
false

:function_not_exported ->
Logger.info(
"your module `#{module}` defined in config is not a maru router, ignore..."
)
Logger.info("your module `#{module}` defined in config is not a maru router, ignore...")

false

Expand Down
2 changes: 1 addition & 1 deletion lib/maru/server.ex
Expand Up @@ -97,7 +97,7 @@ defmodule Maru.Server do
@default_scheme :http
@default_ports http: 4000, https: 4040
@default_bind_addr {127, 0, 0, 1}
@default_adapter Plug.Adapters.Cowboy2
@default_adapter Plug.Cowboy
defp config(opts) do
adapter = opts[:adapter] || @default_adapter
scheme = opts[:scheme] || @default_scheme
Expand Down
2 changes: 1 addition & 1 deletion lib/maru/supervisor.ex
Expand Up @@ -27,7 +27,7 @@ defmodule Maru.Supervisor do
[]

servers ->
Logger.warn "Start server by maru supervisor is deprecated, in favor of Maru.Server."
Logger.warn("Start server by maru supervisor is deprecated, in favor of Maru.Server.")

servers
end
Expand Down
11 changes: 6 additions & 5 deletions lib/mix/maru.ex
Expand Up @@ -9,7 +9,7 @@ defmodule Mix.Maru do
apps =
case Mix.Project.apps_paths() do
nil ->
[Mix.Project.config[:app]]
[Mix.Project.config()[:app]]

apps_paths ->
Map.keys(apps_paths)
Expand All @@ -20,11 +20,12 @@ defmodule Mix.Maru do
|> Enum.uniq()
|> case do
[] ->
Mix.shell.error """
warning: could not find Maru servers in any of the apps: #{inspect apps}.
Mix.shell().error("""
warning: could not find Maru servers in any of the apps: #{inspect(apps)}.
Set the servers managed by those applications in your config/config.exs:
config #{inspect hd(apps)}, maru_servers: [...]
"""
config #{inspect(hd(apps))}, maru_servers: [...]
""")

[]

repos ->
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Expand Up @@ -6,7 +6,7 @@ defmodule Maru.Mixfile do
app: :maru,
name: "Maru",
version: "0.13.2",
elixir: "~> 1.3",
elixir: "~> 1.4",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand All @@ -27,8 +27,8 @@ defmodule Maru.Mixfile do

defp deps do
[
{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.1", optional: true},
{:plug, "~> 1.5"},
{:plug, "~> 1.7"},
{:plug_cowboy, "~> 1.0 or ~> 2.0", optional: true},
{:jason, "~> 1.0", optional: true},
{:inch_ex, "~> 0.5", only: :docs},
{:earmark, "~> 1.2", only: :docs},
Expand Down
14 changes: 14 additions & 0 deletions mix.lock
@@ -0,0 +1,14 @@
%{
"cowboy": {:hex, :cowboy, "2.6.1", "f2e06f757c337b3b311f9437e6e072b678fcd71545a7b2865bdaa154d078593f", [:rebar3], [{:cowlib, "~> 2.7.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :cowlib, "2.7.0", "3ef16e77562f9855a2605900cedb15c1462d76fb1be6a32fc3ae91973ee543d2", [:rebar3], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.3", "206eb2e2ac1a794aa5256f3982de7a76bf4579ff91cb28d0e17ea2c9491e46a4", [], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.16.4", "4bf6b82d4f0a643b500366ed7134896e8cccdbab4d1a7a35524951b25b1ec9f0", [], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"inch_ex": {:hex, :inch_ex, "0.5.6", "418357418a553baa6d04eccd1b44171936817db61f4c0840112b420b8e378e67", [], [{:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"},
"jason": {:hex, :jason, "1.0.0", "0f7cfa9bdb23fed721ec05419bcee2b2c21a77e926bce0deda029b5adc716fe2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.7.1", "8516d565fb84a6a8b2ca722e74e2cd25ca0fc9d64f364ec9dbec09d33eb78ccd", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}], "hexpm"},
"plug_cowboy": {:hex, :plug_cowboy, "2.0.0", "ab0c92728f2ba43c544cce85f0f220d8d30fc0c90eaa1e6203683ab039655062", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [], [], "hexpm"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
}
16 changes: 7 additions & 9 deletions test/server_test.exs
Expand Up @@ -36,23 +36,21 @@ defmodule Maru.ServerTest do
{:ranch_listener_sup, :start_link,
[
Maru.ServerTest.R.HTTP,
100,
:ranch_tcp,
[
%{
num_acceptors: 100,
max_connections: 16384,
ip: {127, 0, 0, 1},
port: 4000
],
socket_opts: [ip: {127, 0, 0, 1}, port: 4000]
},
:cowboy_clear,
%{
compress: true,
env: %{
dispatch: [
{:_, [],
[{:_, [], Plug.Adapters.Cowboy2.Handler, {Maru.ServerTest.R, []}}]}
{:_, [], [{:_, [], Plug.Cowboy.Handler, {Maru.ServerTest.R, []}}]}
]
}
},
stream_handlers: [:cowboy_compress_h, Plug.Cowboy.Stream]
}
]},
type: :supervisor
Expand All @@ -62,7 +60,7 @@ defmodule Maru.ServerTest do
test "runtime server" do
{:ok, _pid} = S.start_link([])
assert {:ok, {_, _, 'ok'}} = :httpc.request('http://127.0.0.1:7113')
:ok = Plug.Adapters.Cowboy2.shutdown(Maru.ServerTest.R.HTTP)
:ok = Plug.Cowboy.shutdown(Maru.ServerTest.R.HTTP)
end
end
end