本文整理汇总了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();
});
}