elixir - 使用 Phoenix.Router 自定义 HTTP 动词

标签 elixir phoenix-framework

如何使用 phoenix 框架在 elixir 应用程序中启用自定义 HTTP 动词?

我可以看到宏 getpost 等是如何在 https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/router.ex#L320-L334 中创建的.然而,可能是因为正在使用的嵌套宏架构,我无法实现自定义 HTTP 动词,比如 bla 使用这样的路由器定义:

Phoenix.Router.Scope.route Ical.Router, :match, :bla, "/bla", PageController, :bla, []

虽然不会导致编译器错误,但在执行 BLA/bla HTTP/1.1 请求时会产生 404。

它甚至在尝试模拟 GET 行为时不起作用

Phoenix.Router.Scope.route Ical.Router, :match, :get, "/bla", PageController, :bla, []

如有任何提示,我们将不胜感激!

最佳答案

好吧,我找到了一种使用应用程序的配置文件来实现它的方法。

这个案例的简单实现和 future 可以在这个拉取请求中看到:https://github.com/phoenixframework/phoenix/pull/1234 .

关于elixir - 使用 Phoenix.Router 自定义 HTTP 动词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32802381/

相关文章:

elixir - 获取当前环境名称

session - 当我测试 session 中需要 user_id 的 phoenix Action 时,如何在设置中设置 session ?

performance - 如何微调牛仔的运行时行为?

authentication - Poison 无法编码 JSON (Phoenix)

erlang - 连接到 TCP 客户端 Elixir

elixir - 在 Phoenix 响应中设置 X-Frame-Options

elixir - 如何在主机重启的情况下自动重启 phoenix?

elixir - 这个 Ecto Constraint Error 试图告诉我什么?

elixir - insert_all 不匹配类型 :utc_datetime

postgresql - 使用 Ecto 在 Phoenix 中进行自引用关联