Commit 8a5e45c4 by Spencer Gibb

Merge branch 'routing-nostrip'

parents 658808a3 166ab388
...@@ -33,7 +33,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> { ...@@ -33,7 +33,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
MultivaluedMap<String, String> params; MultivaluedMap<String, String> params;
InputStream requestEntity; InputStream requestEntity;
public RibbonCommand(RestClient restClient, public RibbonCommand(RestClient restClient,
Verb verb, Verb verb,
String uri, String uri,
...@@ -43,7 +42,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> { ...@@ -43,7 +42,6 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
this("default", restClient, verb, uri, headers, params, requestEntity); this("default", restClient, verb, uri, headers, params, requestEntity);
} }
public RibbonCommand(String commandKey, public RibbonCommand(String commandKey,
RestClient restClient, RestClient restClient,
Verb verb, Verb verb,
...@@ -76,11 +74,10 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> { ...@@ -76,11 +74,10 @@ public class RibbonCommand extends HystrixCommand<HttpResponse> {
} }
} }
HttpResponse forward() throws Exception { private HttpResponse forward() throws Exception {
RequestContext context = RequestContext.getCurrentContext(); RequestContext context = RequestContext.getCurrentContext();
Builder builder = HttpRequest.newBuilder(). Builder builder = HttpRequest.newBuilder().
verb(verb). verb(verb).
uri(uri). uri(uri).
......
...@@ -10,4 +10,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -10,4 +10,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("zuul.proxy") @ConfigurationProperties("zuul.proxy")
public class ZuulProxyProperties { public class ZuulProxyProperties {
private String mapping = "/proxy"; private String mapping = "/proxy";
private boolean stripMapping = true; // this is currently the default behaviour
} }
...@@ -44,9 +44,14 @@ public class PreDecorationFilter extends ZuulFilter { ...@@ -44,9 +44,14 @@ public class PreDecorationFilter extends ZuulFilter {
String requestURI = ctx.getRequest().getRequestURI(); String requestURI = ctx.getRequest().getRequestURI();
//remove proxy prefix TODO: only if embedded proxy
String proxyMapping = properties.getMapping(); 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); ctx.put("requestURI", uriPart);
LinkedHashMap<String, String> routesMap = routes.getRoutes(); LinkedHashMap<String, String> routesMap = routes.getRoutes();
......
...@@ -9,6 +9,9 @@ eureka: ...@@ -9,6 +9,9 @@ eureka:
zuul: zuul:
proxy: proxy:
mapping: /api
stripMapping: false
route: route:
testclient: /testing123 testclient: /api/testing123
stores: /stores stores: /api/stores
customers: /api/customers
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment