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


Java HttpServerRequest类代码示例

本文整理汇总了Java中io.vertx.reactivex.core.http.HttpServerRequest的典型用法代码示例。如果您正苦于以下问题:Java HttpServerRequest类的具体用法?Java HttpServerRequest怎么用?Java HttpServerRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpServerRequest类属于io.vertx.reactivex.core.http包,在下文中一共展示了HttpServerRequest类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClientRequest

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
public ClientRequest(HttpServerRequest serverRequest) {
  this.path = serverRequest.path();
  this.method = serverRequest.method();
  this.headers = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.headers());
  this.params = UriHelper.getParams(serverRequest.uri());
  this.formAttributes = MultiMap.caseInsensitiveMultiMap().setAll(serverRequest.formAttributes());
}
 
开发者ID:Cognifide,项目名称:knotx,代码行数:8,代码来源:ClientRequest.java

示例2: mockContext

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
private RoutingContext mockContext(String requestPath, HttpMethod method) {
  RoutingContext context = Mockito.mock(RoutingContext.class);
  HttpServerRequest httpRequest = Mockito.mock(HttpServerRequest.class);
  Mockito.when(context.request()).thenReturn(httpRequest);
  Mockito.when(httpRequest.path()).thenReturn(requestPath);
  Mockito.when(httpRequest.method()).thenReturn(method);
  return context;
}
 
开发者ID:Cognifide,项目名称:knotx,代码行数:9,代码来源:SupportedMethodsAndPathsHandlerTest.java

示例3: httpServerRequestObservableUnmarshall

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
public void httpServerRequestObservableUnmarshall(HttpServer server) {
  Observable<HttpServerRequest> requestObservable = server.requestStream().toObservable();
  requestObservable.subscribe(request -> {
    Observable<MyPojo> observable = request.
      toObservable().
      compose(io.vertx.reactivex.core.ObservableHelper.unmarshaller(MyPojo.class));
  });
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:9,代码来源:RxifiedExamples.java

示例4: findBestOffer

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
private void findBestOffer(HttpServerRequest request) {
    String requestId = String.valueOf(requestIds.getAndIncrement());

    List<Single<JsonObject>> responses = targets.stream()
        .map(t -> webClient
            .get(t.getInteger("port"),
                t.getString("host"),
                t.getString("path"))
            .putHeader("Client-Request-Id",
                String.valueOf(requestId))
            .as(BodyCodec.jsonObject())
            .rxSend()
            .retry(1)
            .timeout(500, TimeUnit.MILLISECONDS,
                RxHelper.scheduler(vertx))
            .map(HttpResponse::body)
            .map(body -> {
                logger.info("#{} received offer {}", requestId,
                    body.encodePrettily());
                return body;
            })
            .onErrorReturnItem(EMPTY_RESPONSE))
        .collect(Collectors.toList());

    Single.merge(responses)
        .reduce((acc, next) -> {
            if (next.containsKey("bid") && isHigher(acc, next)) {
                return next;
            }
            return acc;
        })
        .flatMapSingle(best -> {
            if (!best.containsKey("empty")) {
                return Single.just(best);
            } else {
                return Single.error(new Exception("No offer " +
                    "could be found for requestId=" + requestId));
            }
        })
        .subscribe(best -> {
            logger.info("#{} best offer: {}", requestId,
                best.encodePrettily());
            request.response()
                .putHeader("Content-Type",
                    "application/json")
                .end(best.encode());
        }, error -> {
            logger.error("#{} ends in error", requestId, error);
            request.response()
                .setStatusCode(502)
                .end();
        });
}
 
开发者ID:jponge,项目名称:oracle-javamag-vertx-rxjava,代码行数:54,代码来源:BestOfferServiceVerticle.java

示例5: httpServerRequest

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
public void httpServerRequest(HttpServer server) {
  Observable<HttpServerRequest> requestObservable = server.requestStream().toObservable();
  requestObservable.subscribe(request -> {
    // Process request
  });
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:7,代码来源:RxifiedExamples.java

示例6: httpServerRequestObservable

import io.vertx.reactivex.core.http.HttpServerRequest; //导入依赖的package包/类
public void httpServerRequestObservable(HttpServer server) {
  Observable<HttpServerRequest> requestObservable = server.requestStream().toObservable();
  requestObservable.subscribe(request -> {
    Observable<Buffer> observable = request.toObservable();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:7,代码来源:RxifiedExamples.java


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