凤凰城通配符路线的路径助手(Elixir)
Path helper for a wildcard route in Phoenix (Elixir)
我想为通配符路由使用路径助手,定义如下:
get("/thing/*sub_path", ThingController, :index)
确实有一个路径助手,但它当然不是我需要的:
iex(3)> MyAppWeb.Router.Helpers.thing_path(MyAppWeb.Endpoint, :index, sub_path: "test/thing")
"/thing?sub_path=test%2Fthing"
我需要的是:
"/thing/test/thing"
关于如何实现这一目标的任何线索?
试试这个:
get("/thing/*sub_path", ThingController, :index)
还有这个:
MyAppWeb.Router.Helpers.thing_path(MyAppWeb.Endpoint, :index, ["test", "thing"])
示例:https://gist.github.com/tapajos/b48e0d1b8ef6654ad70a220c8dc1a97c
我想为通配符路由使用路径助手,定义如下:
get("/thing/*sub_path", ThingController, :index)
确实有一个路径助手,但它当然不是我需要的:
iex(3)> MyAppWeb.Router.Helpers.thing_path(MyAppWeb.Endpoint, :index, sub_path: "test/thing")
"/thing?sub_path=test%2Fthing"
我需要的是:
"/thing/test/thing"
关于如何实现这一目标的任何线索?
试试这个:
get("/thing/*sub_path", ThingController, :index)
还有这个:
MyAppWeb.Router.Helpers.thing_path(MyAppWeb.Endpoint, :index, ["test", "thing"])
示例:https://gist.github.com/tapajos/b48e0d1b8ef6654ad70a220c8dc1a97c