Merge branch 'routing-nostrip'

This commit is contained in:
Spencer Gibb
2014-10-17 22:07:44 -06:00
4 changed files with 14 additions and 8 deletions

View File

@@ -33,7 +33,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
MultivaluedMap<String, String> params;
InputStream requestEntity;
public RibbonCommand(RestClient restClient,
Verb verb,
String uri,
@@ -43,7 +42,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
this("default", restClient, verb, uri, headers, params, requestEntity);
}
public RibbonCommand(String commandKey,
RestClient restClient,
Verb verb,
@@ -76,11 +74,10 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
}
}
HttpResponse forward() throws Exception {
private HttpResponse forward() throws Exception {
RequestContext context = RequestContext.getCurrentContext();
Builder builder = HttpRequest.newBuilder().
verb(verb).
uri(uri).

View File

@@ -10,4 +10,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("zuul.proxy")
public class ZuulProxyProperties {
private String mapping = "/proxy";
private boolean stripMapping = true; // this is currently the default behaviour
}

View File

@@ -44,9 +44,14 @@ public class PreDecorationFilter extends ZuulFilter {
String requestURI = ctx.getRequest().getRequestURI();
//remove proxy prefix TODO: only if embedded proxy
String proxyMapping = properties.getMapping();
final String uriPart = requestURI.replace(proxyMapping, ""); //TODO: better strategy?
final String uriPart;
if (properties.isStripMapping()) {
uriPart = requestURI.replace(proxyMapping, ""); //TODO: better strategy?
} else {
uriPart = requestURI;
}
ctx.put("requestURI", uriPart);
LinkedHashMap<String, String> routesMap = routes.getRoutes();

View File

@@ -9,6 +9,9 @@ eureka:
zuul:
proxy:
mapping: /api
stripMapping: false
route:
testclient: /testing123
stores: /stores
testclient: /api/testing123
stores: /api/stores
customers: /api/customers