0

I would like to know if it's possible to make a generic route in Play Framework.

In MVC.Net you can do something like this:

routes.MapRoute("Default",                                             // Route name
                "{controller}/{action}/{id}",                          // URL with parameters
                new { controller = "Home", action = "Index", id = "" } // Parameter defaults);

With the above route, a lot of urls are covered. So it handles:

/customers
/customers/add
/orders/edit/29
etc.

When I want to do this in the Scala Play routing I have to declare a route for each url.

My questions is if it's possible to have some sort of generic routing in Play framework?

Idos
  • 15,053
  • 14
  • 60
  • 75
user369117
  • 775
  • 1
  • 8
  • 19

1 Answers1

0

No, that isn't supported in Play!, all urls to an action must be declared manually in route file.

You have to implement it your own using reflection See How do I invoke a Java method when given the method name as a string?

Community
  • 1
  • 1
thanhpk
  • 3,900
  • 4
  • 29
  • 36