You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Elixir version (elixir -v): 1.17.0 (compiled with Erlang/OTP 26)
Phoenix version (mix deps): 1.7.17
Operating system: Debian
Preamble
I'm building an app that creates an RSS feed for podcast apps and I'm realizing that some popular podcast apps have extremely unexpected behaviours around the RSS feed URLs they accept. Some mandate that the feed/feed images/content URLs have extensions while others actually strip the provided extensions before making a request to my app. It's madness.
To that end, here's what I'm trying to do:
Define a route that can optionally accept an extension
eg: /feed/rss.xml and /feed/rss should resolve to the same controller. This currently works
Crucially, when generating the feed URL to display to users I should include the .xml extension as a best-practice
Actual behavior
When defining a route without any URL parameters, the above goals work as expected:
# In the routerscope"/",MyAppWebdoget"/rss/feed",FeedsController,:rss_feedend# In my viewurl(@conn,~p"/rss/feed")# This works!url(@conn,~p"/rss/feed.xml")# This works!
However, if the route contains a URL parameter then a no route path warning is emitted if I specify an extension:
# In the routerscope"/",MyAppWebdoget"/rss/:source_id/feed",FeedsController,:rss_feedend# In my viewurl(@conn,~p"/rss/#{source}/feed")# This works!url(@conn,~p"/rss/#{source}/feed.xml")# This emits a `no route path` warning
To be clear - both cases route traffic to the correct controller. The only issue is the warning emitted when generating the route.
Expected behavior
Route generation should act like the parameter-free route in the above examples. I should be able to optionally specify an extension in the ~p string
What I've tried/possible alternatives
I suppose I can define the route multiple times, but that's not ideal. Especially when I consider that I also need to implement this functionality for any image/media types that my app can serve
I can use concatenation like: url(@conn, ~p"/rss/#{source}/feed") <> ".xml" but that feels like a bodge
What I'm currently doing is that I've added a plug to strip and ignore incoming extensions but this doesn't solve the issue of the verified route warning
The text was updated successfully, but these errors were encountered:
Environment
Preamble
I'm building an app that creates an RSS feed for podcast apps and I'm realizing that some popular podcast apps have extremely unexpected behaviours around the RSS feed URLs they accept. Some mandate that the feed/feed images/content URLs have extensions while others actually strip the provided extensions before making a request to my app. It's madness.
To that end, here's what I'm trying to do:
/feed/rss.xml
and/feed/rss
should resolve to the same controller. This currently works.xml
extension as a best-practiceActual behavior
When defining a route without any URL parameters, the above goals work as expected:
However, if the route contains a URL parameter then a
no route path
warning is emitted if I specify an extension:To be clear - both cases route traffic to the correct controller. The only issue is the warning emitted when generating the route.
Expected behavior
Route generation should act like the parameter-free route in the above examples. I should be able to optionally specify an extension in the
~p
stringWhat I've tried/possible alternatives
url(@conn, ~p"/rss/#{source}/feed") <> ".xml"
but that feels like a bodgeThe text was updated successfully, but these errors were encountered: