Thang Nguyen
Thang Nguyen

Reputation: 1151

Convention over configuration in Play 2.x

I found that in Play 2.x I have to configure all URL I have (in routes file) to map with controllers' action. It's not as convention as Play 1.x.

Do anyone know how to make it work just like 1.x

Upvotes: 0

Views: 412

Answers (1)

biesior
biesior

Reputation: 55798

It was discussed many times: in Play 2.0 developers decided to make routes fully typesafe - which means that you need to add dedicated route for each action.

From my point of few it's rather good choice, as it enforces on the developers basic type validation 'out-of-the-box' and prevent's hacker's 'blind traversing'.

In general I would recommend to stay with new approach as you will see that's not so bad in usage and as I can see new IDEs (for an example Idea 12) tries to support routes file of Play 2.

On the other hand you can also handle old style 'automatic' routes youself, for an example using a Dynamic part spanning several / or Dynamic parts with custom regular expressions as described in routing documentation anyway in this situation you will need to validate incoming types yourself.

Upvotes: 2

Related Questions