From this post, I am 99% there
playframework, can you route on hostname/subdomains?
Now, I would LOVE to do the following (we have *.dev.alvazan.com and *.dev.alvazan.com pointing to 127.0.0.1 so developers have to be online OR edit their etc/hosts file)…
UNFORTUNATELY, the request object is null so how can I get the full host or domain that was requested???? then our file will work in production, QA, and on a developers machines with no changes. best of all, developers are testing the real routes that will be used in production albeit they are swapped out via this one script that can never change(if only it worked)….
%{
if(request.domain.contains(".dev.")
|| request.domain.startsWith(dev")) {
alvazan = "dev.alvazan.com"
premonitionx = "dev.premonitionx.com"
} else if(request.domain.contains(".demo.")
|| request.domain.startsWith("demo")) {
alvazan = "demo.alvazan.com"
premonitionx = "demo.premonitionx.com"
} else {
alvazan = "alvazan.com"
premonitionx = "premonitionx.com"
}
}%
My routes would then be easily defined as
- GET {company}.${alvazan}/projects
- GET {company}.${alvazan}/project/{projectname}
which would be perfect!!!!
of course expanded, the route under the covers is really one of these three then depending on if the app is in prod, dev, or QA
- GET {company}.alvazan.com/projects
- GET {company}.dev.alvazan.com/projects
- GET {company}.demo.alvazan.com/projects
Exactly what we would be looking for.
NOTE: Hacking the playframework for us is a valid option so pointers there if there is no solutions here would be great!!!!! This is my 3rd day now in the framework and I plan on diving into the code but was hoping it would be later, not so soon.
No, I don’t want a way to swap environments…I want one environment to just work in three contexts with never having to change anything(well not for this routes file at least).
thanks,
Dean
I think if you just put the following in your routes:
then when you retrieve company if you had requested blah.dev.alvazan.com then company should be “blah.dev” and you’ll then be able to route based on that
Alternative you should be able to do the following:
and then add String env to your controller method signature which should separate the env variable within the framework.
Reference on putting routes on domains for others reading this:
http://www.playframework.org/documentation/1.1/releasenotes-1.1#routeHost