java - How to rewrite absolute paths when using play as proxy server? -
i trying use play (java - 2.3) proxy server publicly expose content internal http server.
so far managed of content want show unfortunately of stylesheets , scripts referenced using absolute paths and, of course, 404.
is there workaround or should ask other devs change paths these files?
my routes file looks this:
get /proxy/*path controllers.gateway.testproxy.index(path)
and forward content using method:
public static promise<result> index(string path) { final promise<result> resultpromise = ws.url("http://10.1.0.10:18406/"+path).get().map( new function<wsresponse, result>() { public result apply(wsresponse response) { response().setcontenttype("text/html"); return ok(response.getbody()); } } ); return resultpromise; }
edit: have scripts , stylesheets:
<link rel="stylesheet" type="text/css" href="/fs/style.css"> <script type="text/javascript" src="/fs/js/jquery-1.9.1.min.js"></script>
since resides in same assets folder ("/fs/") map folders require update play routes file every time developer other team change in way resources organised/stored. it's not nice solution imho, live that.
my biggest problem several jquery ajax calls request urls like:
$.ajax({ url: "/query", processdata: false, data: xmldocument });
or
$.ajax({ url: "/queryall", processdata: false, data: xmldocument });
any lot appreciated, thank you.
at end decided go more practical solution: asked other developers change ajax queries , use same uri pattern.
in way, created few different routes on routes file, depending on type of resource/call have forward:
i have like:
get / controllers.gateway.testproxy.index()
and
public static promise<result> index() { final promise<result> resultpromise = ws.url("http://10.1.0.10:18406/").get().map( new function<wsresponse, result>() { public result apply(wsresponse response) { response().setcontenttype("text/html"); return ok(response.getbody()); } } ); return resultpromise; }
for html pages and
get /$file<.*\.js$> controllers.gateway.testproxy.js(file)
for js files. controller same 1 above except response content-type "text/javascript" of course.
regarding ajax queries, under same path , follow same mechanism.
thanks @m-z time.
Comments
Post a Comment