From 3532bf6cd0ba837949568c091d430d478a02ef11 Mon Sep 17 00:00:00 2001 From: Shane Logsdon Date: Sat, 8 Oct 2016 19:09:35 -0400 Subject: [PATCH] v0.10.0 --- lib/http_router.ex | 45 +++++++++++++++++++++++++++++++-------------- mix.exs | 13 ++++++------- mix.lock | 33 +++++++++++++++++++-------------- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/lib/http_router.ex b/lib/http_router.ex index e7259a3..bbe5b9a 100644 --- a/lib/http_router.ex +++ b/lib/http_router.ex @@ -109,10 +109,13 @@ defmodule HttpRouter do # Plugs we want early in the stack parsers_opts = [ parsers: unquote(opts[:parsers]) ] - if :json in parsers_opts[:parsers] do - parsers_opts = parsers_opts - |> Keyword.put(:json_decoder, unquote(opts[:json_decoder])) - end + parsers_opts = + if :json in parsers_opts[:parsers] do + parsers_opts + |> Keyword.put(:json_decoder, unquote(opts[:json_decoder])) + else + parsers_opts + end plug Plug.Parsers, parsers_opts end @@ -126,17 +129,26 @@ defmodule HttpRouter do defaults = [ { :match, [], true }, { :dispatch, [], true } ] - if options[:allow_copy_req_content_type] == true do - defaults = [ { :copy_req_content_type, [], true } | defaults ] - end + defaults = + if options[:allow_copy_req_content_type] == true do + [ { :copy_req_content_type, [], true } | defaults ] + else + defaults + end - if options[:allow_method_override] == true do - defaults = [ { Plug.MethodOverride, [], true } | defaults ] - end + defaults = + if options[:allow_method_override] == true do + [ { Plug.MethodOverride, [], true } | defaults ] + else + defaults + end - if options[:allow_head] == true do - defaults = [ { Plug.Head, [], true } | defaults ] - end + defaults = + if options[:allow_head] == true do + [ { Plug.Head, [], true } | defaults ] + else + defaults + end plugs = Enum.reverse(defaults) ++ Module.get_attribute(env.module, :plugs) @@ -254,7 +266,12 @@ defmodule HttpRouter do :update, :patch, :delete ] # mainly used by `version/2` prepend_path = Keyword.get opts, :prepend_path, nil - if prepend_path, do: prepend_path = "/" <> prepend_path <> "/" + prepend_path = + if prepend_path do + "/" <> prepend_path <> "/" + else + prepend_path + end routes = [ { :get, "#{prepend_path}#{resource}", :index }, diff --git a/mix.exs b/mix.exs index 9294ff4..88024f7 100644 --- a/mix.exs +++ b/mix.exs @@ -3,13 +3,13 @@ defmodule HttpRouter.Mixfile do def project do [ app: :http_router, - version: "0.0.8", + version: "0.10.0", elixir: "~> 1.0", deps: deps, name: "HttpRouter", package: package, description: description, - docs: [ readme: "README.md", main: "README" ], + docs: [ main: "HttpRouter" ], test_coverage: [ tool: ExCoveralls ] ] end @@ -21,12 +21,11 @@ defmodule HttpRouter.Mixfile do defp deps do [ { :cowboy, "~> 1.0" }, { :plug, "~> 1.0" }, - { :poison, "~> 1.4" }, + { :poison, "~> 3.0" }, { :xml_builder, "~> 0.0" }, - { :earmark, "~> 0.1", only: :docs }, - { :ex_doc, "~> 0.7", only: :docs }, - { :inch_ex, "~> 0.3", only: :docs }, - { :excoveralls, "~> 0.3", only: :test }, + { :earmark, "~> 1.0", only: :dev }, + { :ex_doc, "~> 0.14", only: :dev }, + { :excoveralls, "~> 0.5", only: :test }, { :dialyze, "~> 0.2", only: :test } ] end diff --git a/mix.lock b/mix.lock index c82bead..c1f6ea1 100644 --- a/mix.lock +++ b/mix.lock @@ -1,16 +1,21 @@ -%{"cowboy": {:hex, :cowboy, "1.0.4"}, - "cowlib": {:hex, :cowlib, "1.0.2"}, - "dialyze": {:hex, :dialyze, "0.2.0"}, - "earmark": {:hex, :earmark, "0.1.17"}, - "ex_doc": {:hex, :ex_doc, "0.7.3"}, - "excoveralls": {:hex, :excoveralls, "0.3.11"}, - "exjsx": {:hex, :exjsx, "3.2.0"}, - "hackney": {:hex, :hackney, "1.3.0"}, - "idna": {:hex, :idna, "1.0.2"}, +%{"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []}, + "cowboy": {:hex, :cowboy, "1.0.4", "a324a8df9f2316c833a470d918aaf73ae894278b8aa6226ce7a9bf699388f878", [:rebar, :make], [{:cowlib, "~> 1.0.0", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.0", [hex: :ranch, optional: false]}]}, + "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []}, + "dialyze": {:hex, :dialyze, "0.2.1", "9fb71767f96649020d769db7cbd7290059daff23707d6e851e206b1fdfa92f9d", [:mix], []}, + "earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []}, + "ex_doc": {:hex, :ex_doc, "0.14.2", "c89d60db464e8a0849a35dbcd6eed71f2b076c339d0b05b3bb5c90d6bab31e4f", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]}, + "excoveralls": {:hex, :excoveralls, "0.5.6", "35a903f6f78619ee7f951448dddfbef094b3a0d8581657afaf66465bc930468e", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]}, + "exjsx": {:hex, :exjsx, "3.2.1", "1bc5bf1e4fd249104178f0885030bcd75a4526f4d2a1e976f4b428d347614f0f", [:mix], [{:jsx, "~> 2.8.0", [hex: :jsx, optional: false]}]}, + "hackney": {:hex, :hackney, "1.6.1", "ddd22d42db2b50e6a155439c8811b8f6df61a4395de10509714ad2751c6da817", [:rebar3], [{:certifi, "0.4.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.0", [hex: :ssl_verify_fun, optional: false]}]}, + "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []}, "inch_ex": {:hex, :inch_ex, "0.3.3"}, - "jsx": {:hex, :jsx, "2.6.2"}, - "plug": {:hex, :plug, "1.1.1"}, - "poison": {:hex, :poison, "1.4.0"}, - "ranch": {:hex, :ranch, "1.2.1"}, + "jsx": {:hex, :jsx, "2.8.0", "749bec6d205c694ae1786d62cea6cc45a390437e24835fd16d12d74f07097727", [:mix, :rebar], []}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, + "mime": {:hex, :mime, "1.0.1", "05c393850524767d13a53627df71beeebb016205eb43bfbd92d14d24ec7a1b51", [:mix], []}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, + "plug": {:hex, :plug, "1.2.2", "cfbda521b54c92ab8ddffb173fbaabed8d8fc94bec07cd9bb58a84c1c501b0bd", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, + "poison": {:hex, :poison, "3.0.0", "625ebd64d33ae2e65201c2c14d6c85c27cc8b68f2d0dd37828fde9c6920dd131", [:mix], []}, + "ranch": {:hex, :ranch, "1.2.1", "a6fb992c10f2187b46ffd17ce398ddf8a54f691b81768f9ef5f461ea7e28c762", [:make], []}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []}, "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5"}, - "xml_builder": {:hex, :xml_builder, "0.0.6"}} + "xml_builder": {:hex, :xml_builder, "0.0.8", "dea10735e15c91e24582e41ee2d3282b7f0177a5b42d6268096a6221ba83226f", [:mix], []}}