Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 847
user3418832 Avatar asked May 17 '26 02:05

user3418832


2 Answers

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"
like image 199
Gustavo Maloste Avatar answered May 19 '26 16:05

Gustavo Maloste


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

like image 26
Salem Avatar answered May 19 '26 15:05

Salem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!