how to separate the router file of playframework
I want to separate the routes file (conf/routes).It looks not so elegan开发者_运维百科t that one routes file contains so many routes .How can i divide it into several route files and include them in one?
I believe (but you should check as I'm not certain) that you can achieve this with modules. If you write a module with its own routes file, those routes can be loaded at any path, including /
:
conf/routes
GET /path/a MyController.action
* / module:mymodule
mymodule/conf/routes
GET /path/b MyModuleController.action
But that only makes sense if the routes you want to pull out are actually separate enough to justify having their own module. If not, just include them in the same routes file. As Pere Villega says, it's still a lot more concise than many of the alternatives.
There is no way as far as I know. About it looking "elegant", you can break the routes file into "sections" via comments (with #) to avoid visual cluttering.
I would say that routes doesn't lack "elegancy" when you compare it to alternatives (like XML files defining mappings), it's quite easy to understand for new developers and breaking it into pieces would make slightly harder the process of finding a path and modifying its signature, HTTP method or associated controller for no real benefit besides not having to scroll down a bit more. But that's a personal opinion ;)
精彩评论