本文整理匯總了Java中io.reactivex.netty.protocol.http.server.HttpServerBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java HttpServerBuilder類的具體用法?Java HttpServerBuilder怎麽用?Java HttpServerBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpServerBuilder類屬於io.reactivex.netty.protocol.http.server包,在下文中一共展示了HttpServerBuilder類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createServer
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; //導入依賴的package包/類
private HttpServer<ByteBuf, ByteBuf> createServer(final int listenPort) {
HttpServer<ByteBuf, ByteBuf> server = new HttpServerBuilder<ByteBuf, ByteBuf>(listenPort, (
request, response) -> request
.getContent()
.compose(new RequestTransformer())
.filter(bidreq -> bidreq != null)
.compose(new ExternalRequestTransformer())
.compose(new ExternalRequestExecutor(client))
.flatMap(
resp -> {
response.setStatus(resp == null ? HttpResponseStatus.NO_CONTENT
: HttpResponseStatus.OK);
response.writeString(resp == null ? "" : resp.toString());
return response.close();
})).build();
LOG.info("Gateway started...");
return server;
}
示例2: init
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; //導入依賴的package包/類
@BeforeClass
public static void init() {
port = new Random().nextInt(1000) + 4000;
HttpServerBuilder<ByteBuf, ByteBuf> builder
= new HttpServerBuilder<ByteBuf, ByteBuf>(new ServerBootstrap().group(new NioEventLoopGroup(10, new RxServerThreadFactory())), port, new RequestProcessor());
server = builder.build();
// server = RxNetty.createHttpServer(port, new RequestProcessor());
server.start();
}
示例3: setInjector
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
@Inject
public void setInjector(Injector injector) {
HttpServerConfig config = (HttpServerConfig) injector.getInstance(serverConfigKey);
RequestHandler router = injector.getInstance(routerKey);
GovernatorHttpInterceptorSupport<I, O> interceptorSupport = injector.getInstance(interceptorSupportKey);
interceptorSupport.finish(injector);
HttpRequestHandler<I, O> httpRequestHandler = new HttpRequestHandler<I, O>(router, interceptorSupport);
HttpServerBuilder<I, O> builder = KaryonTransport.newHttpServerBuilder(config.getPort(), httpRequestHandler);
if (config.requiresThreadPool()) {
builder.withRequestProcessingThreads(config.getThreadPoolSize());
}
if (injector.getExistingBinding(pipelineConfiguratorKey) != null) {
builder.appendPipelineConfigurator(injector.getInstance(pipelineConfiguratorKey));
}
if (injector.getExistingBinding(metricEventsListenerFactoryKey) != null) {
builder.withMetricEventsListenerFactory(injector.getInstance(metricEventsListenerFactoryKey));
}
httpServer = builder.build().start();
logger.info("Starting server {} on port {}...", nameAnnotation.value(), httpServer.getServerPort());
}
示例4: createHttpServer
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; //導入依賴的package包/類
public static HttpServer<ByteBuf, ByteBuf> createHttpServer(int port, RequestHandler<ByteBuf, ByteBuf> requestHandler) {
return new HttpServerBuilder<ByteBuf, ByteBuf>(port, requestHandler).build();
}
示例5: newHttpServerBuilder
import io.reactivex.netty.protocol.http.server.HttpServerBuilder; //導入依賴的package包/類
public static <I, O> HttpServerBuilder<I, O> newHttpServerBuilder(int port, RequestHandler<I, O> router) {
return RxContexts.newHttpServerBuilder(port, new HttpRequestHandler<I, O>(router), RxContexts.DEFAULT_CORRELATOR);
}