Skip to content

Commit

Permalink
Merge branch 'routing-nostrip'
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Oct 18, 2014
2 parents 658808a + 166ab38 commit 8a5e45c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
MultivaluedMap<String, String> params;
InputStream requestEntity;


public RibbonCommand(RestClient restClient,
Verb verb,
String uri,
Expand All @@ -43,7 +42,6 @@ public RibbonCommand(RestClient restClient,
this("default", restClient, verb, uri, headers, params, requestEntity);
}


public RibbonCommand(String commandKey,
RestClient restClient,
Verb verb,
Expand Down Expand Up @@ -76,11 +74,10 @@ protected HttpResponse run() throws Exception {
}
}

HttpResponse forward() throws Exception {
private HttpResponse forward() throws Exception {

RequestContext context = RequestContext.getCurrentContext();


Builder builder = HttpRequest.newBuilder().
verb(verb).
uri(uri).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
@ConfigurationProperties("zuul.proxy")
public class ZuulProxyProperties {
private String mapping = "/proxy";
private boolean stripMapping = true; // this is currently the default behaviour
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ public Object run() {

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();
Expand Down
7 changes: 5 additions & 2 deletions spring-cloud-netflix-core/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8a5e45c

Please sign in to comment.