本文整理了Java中org.springframework.web.reactive.function.client.WebClient.create()
方法的一些代码示例,展示了WebClient.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.create()
方法的具体详情如下:
包路径:org.springframework.web.reactive.function.client.WebClient
类名称:WebClient
方法名:create
[英]Create a new WebClient with Reactor Netty by default.
[中]默认情况下,使用Reactor Netty创建新的WebClient。
代码示例来源:origin: spring-projects/spring-framework
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
代码示例来源:origin: spring-projects/spring-framework
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
代码示例来源:origin: spring-projects/spring-framework
@Override
@Before
public void setup() throws Exception {
super.setup();
this.webClient = WebClient.create("http://localhost:" + this.port);
}
代码示例来源:origin: spring-cloud/spring-cloud-gateway
@Before
public void setup() throws Exception {
this.server = new ReactorHttpServer();
this.server.setHandler(createHttpHandler());
this.server.afterPropertiesSet();
this.server.start();
// Set dynamically chosen port
this.serverPort = this.server.getPort();
logger.info("SSE Port: "+this.serverPort);
this.gatewayContext = new SpringApplicationBuilder(GatewayConfig.class)
.properties("sse.server.port:"+this.serverPort, "server.port=0", "spring.jmx.enabled=false")
.run();
ConfigurableEnvironment env = this.gatewayContext.getBean(ConfigurableEnvironment.class);
this.gatewayPort = Integer.valueOf(env.getProperty("local.server.port"));
this.webClient = WebClient.create("http://localhost:" + this.gatewayPort + "/sse");
logger.info("Gateway Port: "+this.gatewayPort);
}
代码示例来源:origin: spring-projects/spring-integration
/**
* Create a handler that will send requests to the provided URI using a provided WebClient.
* @param uriExpression A SpEL Expression that can be resolved against the message object and
* {@link org.springframework.beans.factory.BeanFactory}.
* @param webClient The WebClient to use.
*/
public WebFluxRequestExecutingMessageHandler(Expression uriExpression, WebClient webClient) {
super(uriExpression);
this.webClient = (webClient == null ? WebClient.create() : webClient);
this.setAsync(true);
}
代码示例来源:origin: LearningByExample/reactive-ms-example
public SunriseSunsetServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
代码示例来源:origin: LearningByExample/reactive-ms-example
public GeoLocationServiceImpl(final String endPoint) {
this.endPoint = endPoint;
this.webClient = WebClient.create();
}
代码示例来源:origin: kptfh/feign-reactive
protected Builder() {
this(WebClient.create());
}
代码示例来源:origin: hantsy/spring-reactive-sample
@Bean
public WebClient webClient(){
return WebClient.create();
}
代码示例来源:origin: com.holon-platform.reactor/documentation-reactor
@Bean // <2>
public WebClient webClient() {
return WebClient.create();
}
代码示例来源:origin: srpraneeth/spring5-reactive
@GetMapping("/user/{id}")
public Mono<ServerResponse> handleGetUserById(@PathVariable String id) {
return WebClient.create("http://localhost:9000").get().uri("/api/user/" + id)
.accept(MediaType.APPLICATION_JSON).exchange().flatMap(resp -> ServerResponse.ok().body(resp.bodyToMono(User.class), User.class));
}
代码示例来源:origin: spring-projects/spring-framework-issues
public static void main(String[] args) {
WebClient client = WebClient.create("http://localhost:8080");
Flux<WebfluxApplication.Pojo> pojoFlux = client.get().uri("/dummy").retrieve().bodyToFlux(WebfluxApplication.Pojo.class);
pojoFlux.count().block();
}
}
代码示例来源:origin: srpraneeth/spring5-reactive
@GetMapping("/user")
public Mono<ServerResponse> handleGetUsers() {
return WebClient.create("http://localhost:9000").get().uri("/api/user")
.accept(MediaType.APPLICATION_JSON).exchange().flatMap(resp -> ServerResponse.ok().body(resp.bodyToFlux(User.class), User.class));
}
代码示例来源:origin: bclozel/webflux-workshop
@GetMapping(path = "/quotes/feed", produces = TEXT_EVENT_STREAM_VALUE)
@ResponseBody
public Flux<Quote> quotesStream() {
return WebClient.create("http://localhost:8081")
.get()
.uri("/quotes")
.accept(APPLICATION_STREAM_JSON)
.retrieve()
.bodyToFlux(Quote.class)
.share()
.log("io.spring.workshop.tradingservice");
}
}
代码示例来源:origin: rstoyanchev/demo-reactive-spring
public static void main(String[] args) {
WebClient client = WebClient.create("http://localhost:8081");
LocationGenerator gen = new LocationGenerator(40.740900, -73.988000);
Flux<Car> cars = Flux.interval(Duration.ofSeconds(2)).map(i -> new Car(i + 200, gen.location()));
client.post()
.uri("/cars")
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(cars, Car.class)
.retrieve()
.bodyToMono(Void.class)
.block();
}
代码示例来源:origin: rayokota/kafka-graphs
private Flux<GraphAlgorithmId> proxyConfigure(Set<String> groupMembers, String appId, GraphAlgorithmCreateRequest input) {
Flux<GraphAlgorithmId> flux = Flux.fromIterable(groupMembers)
.filter(s -> !s.equals(getHostAndPort()))
.flatMap(s -> {
log.debug("proxy configure to {}", s);
WebClient client = WebClient.create("http://" + s);
return client.post().uri("/pregel")
.accept(MediaType.APPLICATION_JSON)
.header(X_KGRAPH_APPID, appId)
.body(Mono.just(input), GraphAlgorithmCreateRequest.class)
.retrieve()
.bodyToMono(GraphAlgorithmId.class);
});
return flux;
}
代码示例来源:origin: rayokota/kafka-graphs
private Flux<Void> proxyDelete(Set<String> groupMembers, String appId) {
Flux<Void> flux = Flux.fromIterable(groupMembers)
.filter(s -> !s.equals(getHostAndPort()))
.flatMap(s -> {
log.debug("proxy delete to {}", s);
WebClient client = WebClient.create("http://" + s);
return client.delete().uri("/pregel/" + appId)
.accept(MediaType.APPLICATION_JSON)
.header(X_KGRAPH_APPID, appId)
.retrieve()
.bodyToMono(Void.class);
});
return flux;
}
代码示例来源:origin: spring-projects/spring-framework-issues
@Test
public void should_translate_error_to_polish() {
// when
ClientResponse response = WebClient.create().post()
.uri("http://localhost:" + port + "/validate")
.header("Accept-Language", "pl-PL")
.body(Mono.just(new TestBody()), TestBody.class)
.exchange()
.block();
// then
Map body = response.bodyToMono(Map.class).block();
String message = (String) ((Map) (((List) body.get("errors")).get(0))).get("defaultMessage");
Assertions.assertThat(message).isEqualTo("musi być podane");
}
内容来源于网络,如有侵权,请联系作者删除!