如何使用 phoenix 框架在 elixir 应用程序中启用自定义 HTTP 动词?
我可以看到宏 get
、post
等是如何在 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/