WeezHard
WeezHard

Reputation: 2022

Phoenix framework match different pattern on route to different controller

I need to match different patterns on routes to different controller.

Example: to match http://localhost:4000/<_ANY_THING_> to PageController@index, I do:

get "/:page", PageController, :show

Now, I need to add another route that only match to following pattern:

http://localhost:4000/@<_ANY_THING_>

That should match to UserController@profile

How can I do that?

Upvotes: 2

Views: 299

Answers (1)

Gazler
Gazler

Reputation: 84140

There is nothing different for a route containing an @:

get "/@:user", UserController, :profile

Just be sure to put this above anything else that has the potential to match (such as the catch all route in your example.)

Upvotes: 3

Related Questions