Elixir,Phoenix:在路由步骤中注入参数

时间:2017-04-03 14:59:16

标签: erlang elixir phoenix-framework

让我们说我们有一些类似于这些的路线

get "/user-:user/", MyController, :same_action 
get "/user-:user/email-:email/", MyController, :same_action  
get "/user-:user/page-:page/", MyController, :same_action

首先我认为这很简单,我只需要在路线字符串中添加一些内容

get "/user-:user/page-:page/", MyController, :same_action, :some_custom_value

但现在我卡住了 我想要的只是用一个动作来处理它们,但需要弄清楚......(在控制器中可能)......哪条路线匹配并做了类似的事情:

def same_method(conn, params_parsed_from_url) do
  make_search_by(params_parsed_from_url, some_custom_value)
end

提前致谢。

0 个答案:

没有答案