Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Play support separate routes files per environment - dev, uat, prod?

Is it possible to have the following routing in dev mode:

GET  /       controllers.Assets.at(path="/public/ui/dev", file="index.html")
GET  /*file  controllers.Assets.at(path="/public/ui/dev", file)

and the following in production:

GET  /       controllers.Assets.at(path="/public/ui/prod", file="index.html")
like image 359
reen Avatar asked Jan 09 '14 15:01

reen


2 Answers

Yes it is possible. Declare your dev routes in conf/routes, but declare your production routes in conf/prod.routes. Then, have a production configuration file, conf/prod.conf, and put this in it:

include "application.conf"

application.router = "prod.Routes"

Now, when you start your application in production, simply use:

path/to/myapp/bin/myapp -Dconfig.resource=prod.conf -Dhttp.port=...
like image 172
James Roper Avatar answered Nov 12 '22 14:11

James Roper


The solution above works well but means you are duplicating routes for e.g. non-static resources in your routes and prod.routes files.

If you want to keep a single routes file, you can go down the road that johanandren proposes. I use this method quite successfully, and have posted a gist for this method at https://gist.github.com/drcharris/2e3518b212adfa1b6a7f

like image 45
drcharris Avatar answered Nov 12 '22 15:11

drcharris