Commit da6da6d7 by Dave Syer

Re-organise headers in the /trace of Zuul requests

Now they match better what the vanilla /trace data does in terms of object and field names.
parent 24288691
...@@ -182,8 +182,21 @@ public class ProxyRequestHelper { ...@@ -182,8 +182,21 @@ public class ProxyRequestHelper {
if (traces != null) { if (traces != null) {
RequestContext context = RequestContext.getCurrentContext(); RequestContext context = RequestContext.getCurrentContext();
StringBuilder query = new StringBuilder();
for (String param : params.keySet()) {
for (String value : params.get(param)) {
query.append(param);
query.append("=");
query.append(value);
query.append("&");
}
}
info.put("method", verb);
info.put("path", uri);
info.put("query", query.toString());
info.put("remote", true); info.put("remote", true);
info.put("serviceId", context.get("serviceId")); info.put("proxy", context.get("proxy"));
Map<String, Object> trace = new LinkedHashMap<String, Object>(); Map<String, Object> trace = new LinkedHashMap<String, Object>();
Map<String, Object> input = new LinkedHashMap<String, Object>(); Map<String, Object> input = new LinkedHashMap<String, Object>();
trace.put("request", input); trace.put("request", input);
...@@ -196,19 +209,7 @@ public class ProxyRequestHelper { ...@@ -196,19 +209,7 @@ public class ProxyRequestHelper {
} }
input.put(entry.getKey(), value); input.put(entry.getKey(), value);
} }
StringBuilder query = new StringBuilder();
for (String param : params.keySet()) {
for (String value : params.get(param)) {
query.append(param);
query.append("=");
query.append(value);
query.append("&");
}
}
info.put("method", verb);
info.put("uri", uri);
info.put("query", query.toString());
RequestContext ctx = RequestContext.getCurrentContext(); RequestContext ctx = RequestContext.getCurrentContext();
if (!ctx.isChunkedRequestBody()) { if (!ctx.isChunkedRequestBody()) {
if (requestEntity != null) { if (requestEntity != null) {
...@@ -228,7 +229,6 @@ public class ProxyRequestHelper { ...@@ -228,7 +229,6 @@ public class ProxyRequestHelper {
Map<String, Object> trace = (Map<String, Object>) info.get("headers"); Map<String, Object> trace = (Map<String, Object>) info.get("headers");
Map<String, Object> output = new LinkedHashMap<String, Object>(); Map<String, Object> output = new LinkedHashMap<String, Object>();
trace.put("response", output); trace.put("response", output);
info.put("status", "" + status);
for (Entry<String, List<String>> key : headers.entrySet()) { for (Entry<String, List<String>> key : headers.entrySet()) {
Collection<String> collection = key.getValue(); Collection<String> collection = key.getValue();
Object value = collection; Object value = collection;
...@@ -237,6 +237,7 @@ public class ProxyRequestHelper { ...@@ -237,6 +237,7 @@ public class ProxyRequestHelper {
} }
output.put(key.getKey(), value); output.put(key.getKey(), value);
} }
output.put("status", "" + status);
} }
} }
......
...@@ -55,7 +55,7 @@ public class PreDecorationFilter extends ZuulFilter { ...@@ -55,7 +55,7 @@ public class PreDecorationFilter extends ZuulFilter {
String location = route.getLocation(); String location = route.getLocation();
if (location != null) { if (location != null) {
ctx.put("requestURI", route.getPath()); ctx.put("requestURI", route.getPath());
ctx.put("proxy", route.getId()); ctx.put("proxy", route.getId());
......
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