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")
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=...
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
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