本文整理汇总了Java中org.springframework.web.reactive.function.client.ClientRequest.url方法的典型用法代码示例。如果您正苦于以下问题:Java ClientRequest.url方法的具体用法?Java ClientRequest.url怎么用?Java ClientRequest.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.reactive.function.client.ClientRequest
的用法示例。
在下文中一共展示了ClientRequest.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createNewSpan
import org.springframework.web.reactive.function.client.ClientRequest; //导入方法依赖的package包/类
/**
* Enriches the request with proper headers and publishes
* the client sent event
*/
private Span createNewSpan(ClientRequest request, Span optionalParent) {
URI uri = request.url();
String spanName = getName(uri);
Span newSpan;
if (optionalParent == null) {
newSpan = tracer().createSpan(spanName);
} else {
newSpan = tracer().createSpan(spanName, optionalParent);
}
addRequestTags(request);
newSpan.logEvent(Span.CLIENT_SEND);
if (log.isDebugEnabled()) {
log.debug("Starting new client span [" + newSpan + "]");
}
return newSpan;
}
示例2: filter
import org.springframework.web.reactive.function.client.ClientRequest; //导入方法依赖的package包/类
@Override
public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next) {
URI originalUrl = request.url();
String serviceId = originalUrl.getHost();
Assert.state(serviceId != null, "Request URI does not contain a valid hostname: " + originalUrl);
//TODO: reactive lb client
ServiceInstance instance = this.loadBalancerClient.choose(serviceId);
URI uri = this.loadBalancerClient.reconstructURI(instance, originalUrl);
ClientRequest newRequest = ClientRequest.method(request.method(), uri)
.headers(headers -> headers.addAll(request.headers()))
.cookies(cookies -> cookies.addAll(request.cookies()))
.attributes(attributes -> attributes.putAll(request.attributes()))
.body(request.body())
.build();
return next.exchange(newRequest);
}