实例
public class ModifyResponseBodyFilter extends ZuulFilter {
public String filterType() {
return "post";
}
public int filterOrder() {
return 999;
}
public boolean shouldFilter() {
return true;
}
public Object run() {
try {
RequestContext context = getCurrentContext();
InputStream stream = context.getResponseDataStream();
String body = StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
context.setResponseBody("new body: "+body);
}
catch (IOException e) {
rethrowRuntimeException(e);
}
return null;
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。