以下配置接受带有要创建的用户实例的 JSON 请求正文的 HTTP POST,但如果我能让它返回一个201 Created
. 有任何想法吗?
@Bean
public IntegrationFlow flow(UserService userService) {
return IntegrationFlows.from(
Http.inboundGateway("/users")
.requestMapping(r -> r.methods(HttpMethod.POST))
.statusCodeFunction(f -> HttpStatus.CREATED)
.requestPayloadType(User.class)
.replyChannel(replyChannel())
.requestChannel(inputChannel())
)
.handle((p, h) -> userService.create((User) p)).get();
}
我尝试调用statusCodeFunction
,HttpRequestHandlerEndpointSpec
但我一定做错了。