Central point to manipulate UriInfo
I am currently utilizing UriInfo, injected by jax-rs framework (currently RestEasy), to build the URI that I use in the Location header. The url created from the UriInfo is also used in the response xml/json.
So in short it looks some thing li开发者_如何学Pythonke:
public class ResourceBean {
@Context
private UriInfo uriInfo
public Response mappedMethod(){
...
UriBuilder builder = uriInfo.getBaseUriBuilder().path(...);
...
}
}
The problem is that we use load balancers in front of the application servers and if a user/system is to follow one of the links it needs to go via the load balancers and not directly to this machine. uriInfo.getBaseUriBuilder()
returns the base URL of the current machine and not of the load balancers.
I understand that some load balancers can do url rewritting to achieve this, but I unfortunately don't have any control or access to our load balancers and don't know if they support it, or if it is even possible in the body of the html response.
Is there a central point where the UriInfo can be manipulated or contstructed to contain the load balancer's base URI?
I have found where the UriInfo is constructed. The information is gathered from HttpServletRequest. Unfortunately there is no way other then changing RestEasy code to manipulate it.
So I am going to use a Servlet Filter to manipulate the request before it hits the framework.
精彩评论