本文介绍了有没有一种方法可以仅在一条路线上安装Phoenix插头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在凤凰城,我的路线如下:

In Phoenix I have my routes as follow :

  scope "/", ManaWeb do
    pipe_through [:browser, :auth]
    get "/register",  RegistrationController, :new
    post "/register", RegistrationController, :register
  end

但是我想为最后一条路线(POST)设置一个插头.

However I would like to set a Plug for the last route (POST).

我将如何使用当前的工具进行处理?

How would I go about that with current tools ?

推荐答案

Phoenix.Router.pipeline/2

也就是说,这可以工作:

That said, this would work:

scope "/", ManaWeb do
  pipe_through [:browser, :auth]
  get "/register",  RegistrationController, :new

  pipe_through :post_plug
  post "/register", RegistrationController, :register
end

这篇关于有没有一种方法可以仅在一条路线上安装Phoenix插头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 17:07