本文整理匯總了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());
}
示例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;
}
示例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));
});
}
示例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();
});
}
示例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
});
}
示例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();
});
}