【发布时间】:2020-05-11 22:09:17
【问题描述】:
我正在使用 Spring WebFlux,我正在接受请求并使用相同的请求来调用另一个服务。但我不确定如何添加查询参数。这是我的代码
@RequestMapping(value= ["/ptta-service/**"])
suspend fun executeService(request: ServerHttpRequest): ServerHttpResponse {
val requestedPath = if (request.path.toString().length > 13) "" else request.path.toString().substring(13)
return WebClient.create(this.dataServiceUrl)
.method(request.method ?: HttpMethod.GET)
.uri(requestedPath)
.header("Accept", "application/json, text/plain, */*")
.body(BodyInserters.fromValue(request.body))
.retrieve()
.awaitBody()
// But how about query parameters??? How to add those
}
虽然代码在 Kotlin 中,但 Java 也会有所帮助。
【问题讨论】:
标签: java kotlin spring-webflux spring-webclient