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?
In current version (2.5) of play, the appropriate way is to add the desired base path to the play.http.context in the application.conf
play.http.context="/v1"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With