gpt4 book ai didi

org.springframework.web.server.WebHandler类的使用及代码示例

转载 作者:知者 更新时间:2024-03-24 14:43:05 25 4
gpt4 key购买 nike

本文整理了Java中org.springframework.web.server.WebHandler类的一些代码示例,展示了WebHandler类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebHandler类的具体详情如下:
包路径:org.springframework.web.server.WebHandler
类名称:WebHandler

WebHandler介绍

[英]Contract to handle a web request.

Use HttpWebHandlerAdapter to adapt a WebHandler to an org.springframework.http.server.reactive.HttpHandler. The WebHttpHandlerBuilder provides a convenient way to do that while also optionally configuring one or more filters and/or exception handlers.
[中]处理web请求的合同。
使用HttpWebHandlerAdapter使WebHandler适应组织。springframework。http。服务器反应性。HttpHandler。WebHttpHandlerBuilder提供了一种方便的方法来实现这一点,同时还可以选择配置一个或多个过滤器和/或异常处理程序。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<Void> handle(ServerWebExchange exchange) {
  return this.delegate.handle(exchange);
}

代码示例来源:origin: org.springframework/spring-web

@Override
public Mono<Void> handle(ServerWebExchange exchange) {
  return this.delegate.handle(exchange);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
  WebHandler webHandler = (WebHandler) handler;
  Mono<Void> mono = webHandler.handle(exchange);
  return mono.then(Mono.empty());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
  return Mono.defer(() ->
      this.currentFilter != null && this.next != null ?
          this.currentFilter.filter(exchange, this.next) :
          this.handler.handle(exchange));
}

代码示例来源:origin: org.springframework/spring-web

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
  return Mono.defer(() ->
      this.currentFilter != null && this.next != null ?
          this.currentFilter.filter(exchange, this.next) :
          this.handler.handle(exchange));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void webExceptionHandler() {
  ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/unknown-argument-type"));
  List<WebExceptionHandler> handlers = Collections.singletonList(new ServerError500ExceptionHandler());
  WebHandler webHandler = new ExceptionHandlingWebHandler(this.dispatcherHandler, handlers);
  webHandler.handle(exchange).block(Duration.ofSeconds(5));
  assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, exchange.getResponse().getStatusCode());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void thrownExceptionBecomesErrorSignal() throws Exception {
  createWebHandler(new BadRequestExceptionHandler()).handle(this.exchange).block();
  assertEquals(HttpStatus.BAD_REQUEST, this.exchange.getResponse().getStatusCode());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void handleErrorSignal() throws Exception {
  createWebHandler(new BadRequestExceptionHandler()).handle(this.exchange).block();
  assertEquals(HttpStatus.BAD_REQUEST, this.exchange.getResponse().getStatusCode());
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void handleErrorSignalWithMultipleHttpErrorHandlers() throws Exception {
  createWebHandler(
      new UnresolvedExceptionHandler(),
      new UnresolvedExceptionHandler(),
      new BadRequestExceptionHandler(),
      new UnresolvedExceptionHandler()).handle(this.exchange).block();
  assertEquals(HttpStatus.BAD_REQUEST, this.exchange.getResponse().getStatusCode());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
  if (this.forwardedHeaderTransformer != null) {
    request = this.forwardedHeaderTransformer.apply(request);
  }
  ServerWebExchange exchange = createExchange(request, response);
  LogFormatUtils.traceDebug(logger, traceOn ->
      exchange.getLogPrefix() + formatRequest(exchange.getRequest()) +
          (traceOn ? ", headers=" + formatHeaders(exchange.getRequest().getHeaders()) : ""));
  return getDelegate().handle(exchange)
      .doOnSuccess(aVoid -> logResponse(exchange))
      .onErrorResume(ex -> handleUnresolvedError(exchange, ex))
      .then(Mono.defer(response::setComplete));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void unresolvedException() throws Exception {
  Mono<Void> mono = createWebHandler(new UnresolvedExceptionHandler()).handle(this.exchange);
  StepVerifier.create(mono).expectErrorMessage("boo").verify();
  assertNull(this.exchange.getResponse().getStatusCode());
}

代码示例来源:origin: org.springframework/spring-web

@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
  if (this.forwardedHeaderTransformer != null) {
    request = this.forwardedHeaderTransformer.apply(request);
  }
  ServerWebExchange exchange = createExchange(request, response);
  LogFormatUtils.traceDebug(logger, traceOn ->
      exchange.getLogPrefix() + formatRequest(exchange.getRequest()) +
          (traceOn ? ", headers=" + formatHeaders(exchange.getRequest().getHeaders()) : ""));
  return getDelegate().handle(exchange)
      .doOnSuccess(aVoid -> logResponse(exchange))
      .onErrorResume(ex -> handleUnresolvedError(exchange, ex))
      .then(Mono.defer(response::setComplete));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public Mono<Void> handle(ServerWebExchange exchange) {
  return this.delegate.handle(exchange);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Mono<Void> handle(ServerWebExchange exchange) {
  return this.delegate.handle(exchange);
}

代码示例来源:origin: org.springframework/spring-web-reactive

@Override
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
  WebHandler webHandler = (WebHandler) handler;
  Mono<Void> mono = webHandler.handle(exchange);
  return mono.then(aVoid -> Mono.empty());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
  return Mono.defer(() ->
      this.currentFilter != null && this.next != null ?
          this.currentFilter.filter(exchange, this.next) :
          this.handler.handle(exchange));
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Mono<Void> filter(ServerWebExchange exchange) {
  return Mono.defer(() -> {
    if (this.index < this.filters.size()) {
      WebFilter filter = this.filters.get(this.index);
      WebFilterChain chain = new DefaultWebFilterChain(this, this.index + 1);
      return filter.filter(exchange, chain);
    }
    else {
      return this.handler.handle(exchange);
    }
  });
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
  ServerWebExchange exchange = createExchange(request, response);
  return getDelegate().handle(exchange)
      .onErrorResume(ex -> handleFailure(request, response, ex))
      .then(Mono.defer(response::setComplete));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

@Override
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
  if (this.forwardedHeaderTransformer != null) {
    request = this.forwardedHeaderTransformer.apply(request);
  }
  ServerWebExchange exchange = createExchange(request, response);
  LogFormatUtils.traceDebug(logger, traceOn ->
      exchange.getLogPrefix() + formatRequest(exchange.getRequest()) +
          (traceOn ? ", headers=" + formatHeaders(exchange.getRequest().getHeaders()) : ""));
  return getDelegate().handle(exchange)
      .doOnSuccess(aVoid -> logResponse(exchange))
      .onErrorResume(ex -> handleUnresolvedError(exchange, ex))
      .then(Mono.defer(response::setComplete));
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com