siepet
Forwarded route with scoped paths
Hello, I have an main application router, which routes to different contexts, ie:
scope "/users/:id", as: user do
scope "/events", as: event do
use Event.Router
end
scope "/contacts", as: :contact do
use Contact.Router
end
end
and each of contexts’ router has a defined macro like this:
defmacro __using__() do
quote do
scope "/", Event do
get("/", EventController, :index)
end
end
end
And right now, I’m trying to switch this to Phoenix.Router — Phoenix v1.8.8
So I did this in main router:
scope "/users/:id", as: user do
scope "/event", as: :event do
forward "/event", Event.Router
end
end
But with router as Event.Router is shown, it doesn’t work, because it won’t catch the :id from the parent router.
At first, I’ve tried this:
# Event.Router
scope "/users/:id", Event do
get("/", EventController, :index)
end
But then it shows me this error:
** (Phoenix.Router.NoRouteError) no route found for GET /events (Event.Router)
and having this, fixes the error, but I don’t think this should be the solution:
# Event.Router
get("/events", EventController, :index)
scope "/users/:id", Event do
get("/events", EventController, :index)
end
What should be correct approach here?
First Post!
OvermindDL1
I’ve been curious in this too, would simplify things, right now I’m parsing the path after the fact, which is not very clean.
0
Popular in Questions
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Other popular topics
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I would like to know what is the best IDE for elixir development?
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
What learn first? Rust or Elixir
Hi Elixir community!
I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









