Using Play Framework 2.0.4, I’d like to define my static content URLS differently regarding the environment.
In DEV mode, it would be /public/{here}, so using the default configuration of
GET /public/*file controllers.Assets.at(path="/public", file)
is good, but in PROD, I want to use the http://static.mydomain.com/ base URL.
At first, I thought about changing the Assets like this :
GET /public/*file controllers.Assets.at(path="http://static.mydomain.com/", file)
But of course, it doesn’t work.
So I was thinking about using a static method that would look in the application.conf file for a application.staticBaseUrl parameter, and return either /public/{here} or http://static.mydomain.com/{here}, or anything defined in the application.conf param.
But I’m not sure if it’s the best way, neither if there isn’t already a better way to do so.
You can add static wrapper ie in you
Applicationcontroller:so you can use it in your views with:
Expanded version
I’m using also expanded version of this when working with several CDN’s ie (or using dummy subdomain-CDNs for faster resource downloading):
Application.confcontroller:
view: