Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法获取body #3

Open
wcp1230 opened this issue Jan 7, 2019 · 1 comment
Open

无法获取body #3

wcp1230 opened this issue Jan 7, 2019 · 1 comment

Comments

@wcp1230
Copy link

wcp1230 commented Jan 7, 2019

RouteLocator 配置信息
@bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()//
.route(p -> p.path("/a/") .uri("lb://a"))
.route(p -> p.path("/b/
") .uri("lb://b"))

			.build();
}

ReadBodyPredicateFactory:
当前使用的版本的代码如下:
return bodyInserter.insert(outputMessage, new BodyInserterContext())
// .log("modify_request", Level.INFO)
.then(Mono.defer(() -> {
boolean test = (Boolean) exchange.getAttributes()
.getOrDefault(TEST_ATTRIBUTE, Boolean.FALSE);
exchange.getAttributes().remove(TEST_ATTRIBUTE);
exchange.getAttributes().put(CACHED_REQUEST_BODY_KEY,
outputMessage.getBody());
return Mono.just(test);
}));
};

GlobalLogFilter:
private static final String CACHED_REQUEST_BODY_KEY = "cachedRequestBody";
String bodyStr = exchange.getAttribute(CACHED_REQUEST_BODY_KEY);

bodyStr 还是为空,是需要啥配置才能获取到数据呢?

@wannibar
Copy link

wannibar commented Jul 4, 2022

这破竹就是在瞎写

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants