當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。