From 8e3a213cb8cc752904f9ceb9453651502ac200c7 Mon Sep 17 00:00:00 2001 From: Stefan Fochler Date: Sun, 27 Sep 2015 17:40:11 +0100 Subject: [PATCH] Router creates macros for additional http methods In the __before_compile__ macro, Phoenix.Router can retrieve additional http methods and create the macros just as with the stock methods. --- lib/phoenix/router.ex | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/phoenix/router.ex b/lib/phoenix/router.ex index dc0d92bdc2..2e73256611 100644 --- a/lib/phoenix/router.ex +++ b/lib/phoenix/router.ex @@ -317,7 +317,19 @@ defmodule Phoenix.Router do end end - for verb <- @http_methods do + # Allow additional http methods being set by using the project's config file: + # + # ## Example config.exs: + # + # config :phoenix, :router, + # additional_http_methods: [:mymethod] + # + additional_http_methods = Application.get_env(:phoenix, :router) || [] + |> Keyword.get(:additional_http_methods) + + http_methods = @http_methods ++ (additional_http_methods || []) + + for verb <- http_methods do @doc """ Generates a route to handle a #{verb} request to the given path. """