Saturday, 31 August 2013

Application name changes on AWS - how to retrieve resources, which URL or method to use?

Application name changes on AWS - how to retrieve resources, which URL or
method to use?

For example:
applicationSuperName - using this local server name requests build like:
applicationSuperName/home
This web app is deployed into cloud and has:
Public DNS: ec2-23-213-211-f222.eu-west-1.compute.amazonaws.com/home
Some_elastic_IP/home
- elastic ip address
mysuperdomain.com - My domain name attached to elastic IP
My resources(css, js, images) are under applicationSuperName/resources
(locally) , in cloud this folder will be resolved by using elastic IP
address or domain name, but I do no want to include either of these two
parameters into links in my app. (so it would be context independent)
So I can't use:
<link href="/applicationSuperName/resources/css/bootstrap.min.css
rel="stylesheet">
(because application name becomes purchased domain name or IP)
or I can't use:
<link href=".resources/css/bootstrap.min.css" rel="stylesheet">
(because this is request relevant with this part building on top thus the
location for any other request except for root page becomes
applicationSuperName/home/resources/css/bootstrap.min.css which is totally
incorrect)
How to make url request which would go on second level after any
application name and goes to my resources folder?
I came up solution namely using request .getServerName(), but I strongly
believe this is overkill and may has some negative impact, since I have to
call it for each request and page, or check for this variable(like in
session) if I want to use say spring:url tag(to substitute app name and do
usual style like "spring:url/resources").
Please advice if the latter is acceptable or suggest other way to resolve
resources correctly regardless of the app name.

No comments:

Post a Comment