user3418832 user3418832 - 4 months ago 17
Java Question

custom base path play framework

Is there a way to configure a custom root base path for all the routes?

for example:

/login
/user
/group


but I want to prepend everything with:

/v1/login
/v1/user
/v1/group


anyway to do it via a application.conf?

Answer

Yes. Suppose your routes file has the following routes

GET /login  controllers.login()
GET /user   controllers.user()
GET /group  controllers.group()

To achieve what you want, you just have to rename or move that rules to a new file (for example v1.routes) and then in the main routes file, use

->      /v1     v1.Routes

All the routes present in v1 file are now prepended with v1

Comments