`scope` in router and plug from another namespace

I have a scope like the following:

scope "/some-scope", MyAppWeb do
  pipe_through :browser

  post "/some-route", SomeController, :some_action 

  post "/another-route", AnotherController, :another_action

  forward "/another-route", PlugFromAnotherNamespace
 
  post "/and-another-route", AndAnotherController, :and_another_action 

  # ...

end

The problem is that the PlugFromAnotherNamespace module is not inside MyAppWeb and the code will try to call MyAppWeb.PlugFromAnotherNamespace.

What is the best solution for this? The order of the routes matter, and I need this plug to be at that specific place.

scope "/some-scope" do
  pipe_through :browser

  post "/some-route", MyAppWeb.SomeController, :some_action 

  post "/another-route", MyAppWeb.AnotherController, :another_action

  forward "/another-route", PlugFromAnotherNamespace
 
  post "/and-another-route", MyAppWeb.AndAnotherController, :and_another_action 

  # ...

end
2 Likes