当前位置: 首页>>代码示例>>Java>>正文


Java ClientRequest.url方法代码示例

本文整理汇总了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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:21,代码来源:TraceWebClientBeanPostProcessor.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:18,代码来源:LoadBalancerExchangeFilterFunction.java


注:本文中的org.springframework.web.reactive.function.client.ClientRequest.url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。