In the Phoenix router is there a route that could act as a wildcard?
Asked
Active
Viewed 8,585 times
1 Answers
115
Ah, the famous pokemon route:
get "/*path"
You will find the paths inside conn.params["path"]
or as conn.path_info
.

José Valim
- 50,409
- 12
- 130
- 115
-
28Ah...took me a while..."Gotta catch 'em all" – Micah Jan 13 '16 at 22:33
-
1@JoseValim For wildcard routes, how would the path helpers work? For example, let's say you have this line: `get "/*path", RedirectController, :handle_redirect` how would you write `redirect_path(MyApp.Endpoint, :handle_redirect, ???)`. What would the last argument be? I tried various things and none of them worked. – jduan Apr 27 '16 at 06:12
-
2IIRC it should be a list of paths: ["foo", "bar", "baz"] – José Valim May 08 '16 at 20:21
-
5When using this technique I also found it useful to check the value of `conn.request_path`, because it contains the actual path as opposed to the list of path components available in `conn.path_info`. – tompave Oct 16 '16 at 21:57