本文整理汇总了Java中io.vertx.core.http.HttpServerOptions类的典型用法代码示例。如果您正苦于以下问题:Java HttpServerOptions类的具体用法?Java HttpServerOptions怎么用?Java HttpServerOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpServerOptions类属于io.vertx.core.http包,在下文中一共展示了HttpServerOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testbuildHttpServerOptionsRequest
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Test
public void testbuildHttpServerOptionsRequest() {
SSLOption option = SSLOption.buildFromYaml("rest.provider");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpServerOptions serverOptions = new HttpServerOptions();
new MockUp<SSLOption>() {
@Mock
public boolean isAuthPeer() {
return false;
}
};
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
示例2: start
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Override
public void start() throws Exception {
final Router router = Router.router(vertx);
final HttpServerOptions httpServerOptions = new HttpServerOptions();
httpServerOptions.setPort(8900);
final HttpServer http = vertx.createHttpServer(httpServerOptions);
SwaggerHandler.registerToRouter(router, MyApp.class);
final JaxRsRouter jaxRsRouter = new JaxRsRouter();
final SpringJaxRsHandler handler = new SpringJaxRsHandler(MyApp.class);
jaxRsRouter.register(MyApp.class, router, handler, handler);
ManifestHandler.registerToRouter(router);
http.requestHandler(req -> router.accept(req)).listen(res -> {
if (res.failed()) {
res.cause().printStackTrace();
vertx.close();
}
});
}
示例3: registryRoute
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
public void registryRoute(final String name,
final HttpServerOptions options, final Set<String> routes) {
final String path = MessageFormat.format(ROUTE_TREE, this.etcd.getApplication(),
EtcdPath.ENDPOINT.toString().toLowerCase(),
MessageFormat.format("{0}:{1}:{2}", name,
Net.getIPv4(), String.valueOf(options.getPort())));
final String host = Net.getIPv4();
final String endpoint = MessageFormat.format("http://{0}:{1}",
host,
String.valueOf(options.getPort()));
// Screen Information
final StringBuilder builder = new StringBuilder();
for (final String route : routes) {
builder.append("\n\t[ Up Micro ] \t").append(route);
}
this.logger.info(Info.ETCD_ROUTE, this.etcd.getApplication(),
path, name, endpoint, builder.toString());
// Build Data
final JsonArray routeData = new JsonArray();
Observable.fromIterable(routes)
.subscribe(routeData::add);
this.etcd.write(path, routeData, Values.ZERO);
}
示例4: start
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Override
public void start() {
final EventBus bus = this.vertx.eventBus();
bus.<JsonObject>consumer(ID.Addr.REGISTRY_START, result -> {
final JsonObject data = result.body();
final String name = data.getString(Registry.NAME);
final HttpServerOptions options =
new HttpServerOptions(data.getJsonObject(Registry.OPTIONS));
final String[] uris =
data.getString(Registry.URIS).split(Strings.COMMA);
final Set<String> uriData = new TreeSet<>(Arrays.asList(uris));
// Write the data to registry.
this.registry.registryHttp(name, options, Etat.RUNNING);
this.registry.registryRoute(name, options, uriData);
LOGGER.info(Info.MICRO_REGISTRY_CONSUME, getClass().getSimpleName(),
name, ID.Addr.REGISTRY_START);
});
}
示例5: recordServer
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
private void recordServer(final HttpServerOptions options,
final Router router) {
final Integer port = options.getPort();
final AtomicInteger out = ZeroAtomic.RX_START_LOGS.get(port);
if (Values.ZERO == out.getAndIncrement()) {
// 1. Build logs for current server;
final String portLiteral = String.valueOf(port);
LOGGER.info(Info.RX_SERVERS, this.NAME, deploymentID(),
portLiteral);
final List<Route> routes = router.getRoutes();
final Map<String, Route> routeMap = new TreeMap<>();
for (final Route route : routes) {
// 2.Route
final String path = null == route.getPath() ? "/*" : route.getPath();
routeMap.put(path, route);
}
routeMap.forEach((path, route) ->
LOGGER.info(Info.MAPPED_ROUTE, this.NAME, path,
route.toString()));
// 3. Endpoint Publish
final String address =
MessageFormat.format("http://{0}:{1}/",
options.getHost(), portLiteral);
LOGGER.info(Info.RX_LISTEN, this.NAME, address);
}
}
示例6: start
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(BodyHandler.create().setUploadsDirectory("upload-files"));
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)).setNagHttps(false));
router.route().handler(RequestSecurePreprocessor.create());
RouteRegister.registerRouters(router, "com.dms.secure", "com.dms.api", "com.dms.templates");
router.route("/js/*").handler(StaticHandler.create().setCachingEnabled(false).setWebRoot("WEB-INF/js/"));
/*
* @see com.dms.planb.support .TableDropper
*/
HttpServerOptions httpOpts = new HttpServerOptions();
/*System.out.println(SecureConfig.get("SSL_PATH"));
System.out.println(SecureConfig.get("SSL"));
httpOpts.setSsl(true)
.setKeyStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")))
.setTrustStoreOptions(new JksOptions().setPath(SecureConfig.get("SSL_PATH")).setPassword(SecureConfig.get("SSL")));
*/
vertx.createHttpServer(httpOpts).requestHandler(router::accept).listen(Integer.parseInt(SecureConfig.get("SERVER_PORT")));
}
示例7: start
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
public void start() {
sdk = null;
config = null;
if (server == null) {
Vertx vertx = Vertx
.vertx(new VertxOptions().setWorkerPoolSize(40).setBlockedThreadCheckInterval(1000L * 60L * 10L)
.setMaxWorkerExecuteTime(1000L * 1000L * 1000L * 60L * 10L));
HttpServerOptions options = new HttpServerOptions();
options.setMaxInitialLineLength(HttpServerOptions.DEFAULT_MAX_INITIAL_LINE_LENGTH * 2);
server = vertx.createHttpServer(options);
router = Router.router(vertx);
}
retrieveConfig();
if (config == null || config.isApiKeyEmpty()) {
logError("Unable to find " + String.valueOf(ENVVAR_MBED_CLOUD_API_KEY) + " environment variable");
System.exit(1);
}
defineInitialisationRoute();
defineModuleMethodTestRoute();
logInfo("Starting Java SDK test server on port " + String.valueOf(port) + "...");
server.requestHandler(router::accept).listen(port);
}
示例8: setUp
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
vertx = Vertx.vertx();
JsonObject config = vertx.getOrCreateContext().config();
Router router = Router.router(vertx);
configuration = new VertxConfiguration(config);
configuration.put(SSL_CONFIGURATION_KEY, FALSE);
configuration.put(SSL_JKS_PATH, TEST_JKS_PATH);
configuration.put(SSL_JKS_SECRET, TEST_JKS_SECRET);
configuration.put(HTTPS_PORT, DEFAULT_HTTPS_PORT);
options = new HttpServerOptions();
context = VertxContext.VertxContextBuilder.vertx(vertx)
.router(router)
.serverConfiguration(configuration)
.vertxServiceDiscovery(new VertxServiceDiscovery(vertx)).build();
}
示例9: init
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Override
protected void init() {
super.init();
profile = DEFAULT_PROFILE;
owner = DEFAULT_OWNER;
serialKey = UUID.randomUUID().toString();
gatewayDatabaseOptions = new GatewayDatabaseOptions();
apiPort = DEFAULT_API_PORT;
proxyPort = DEFAULT_PROXY_PORT;
dashboardPort = DEFAULT_DASHBOARD_PORT;
httpServerOptions = new HttpServerOptions();
periodicHealthCheck = DEFAULT_PERIOD_HEALTH_CHECK;
audit = DEFAULT_AUDIT_OPTION;
libPath = DEFAULT_LIB_PATH;
}
示例10: configSSL
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
private HttpServerOptions configSSL(JsonObject conf) {
String ssl_keystore= conf.getString("ssl.keystore");
String keystore_pass = conf.getString("ssl.keystore.pass");
String ssl_client_keystore= conf.getString("ssl.client.keystore");
String client_keystore_pass = conf.getString("ssl.client.keystore.pass");
HttpServerOptions options = new HttpServerOptions();
options.setCompressionSupported(true);
if(S.isNotBlank(ssl_keystore) && S.isNotBlank(keystore_pass)){
options.setSsl(true).setKeyStoreOptions(
new JksOptions().setPath(ssl_keystore).setPassword(keystore_pass));
if(S.isNotBlank(ssl_client_keystore) && S.isNotBlank(client_keystore_pass))
options.setClientAuth(ClientAuth.REQUIRED).setTrustStoreOptions(
new JksOptions().setPath(ssl_client_keystore).setPassword(client_keystore_pass));
}
return options;
}
示例11: HttpContainer
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
public HttpContainer(String host, int port, boolean enableLogging) {
this.host = host;
this.port = port;
this.enableLogging = enableLogging;
vertx = Vertx.vertx();
HttpServerOptions options = new HttpServerOptions().setLogActivity(this.enableLogging);
server = vertx.createHttpServer(options);
router = Router.router(vertx);
}
示例12: testbuildHttpServerOptions
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Test
public void testbuildHttpServerOptions() {
SSLOption option = SSLOption.buildFromYaml("rest.provider");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpServerOptions serverOptions = new HttpServerOptions();
VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
示例13: createDefaultHttpServerOptions
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
private HttpServerOptions createDefaultHttpServerOptions() {
HttpServerOptions serverOptions = new HttpServerOptions();
serverOptions.setUsePooledBuffers(true);
serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds());
if (endpointObject.isSslEnabled()) {
SSLOptionFactory factory =
SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
SSLOption sslOption;
if (factory == null) {
sslOption = SSLOption.buildFromYaml(SSL_KEY);
} else {
sslOption = factory.createSSLOption();
}
SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
}
return serverOptions;
}
示例14: start
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
Future<HttpServer> async = Future.future();
(server = vertx.createHttpServer(new HttpServerOptions())).requestHandler(new Irked(vertx).setupRequestHandler(test))
.listen(config().getInteger("port"), async);
async.map((Void) null).setHandler(startFuture);
}
示例15: createOptions
import io.vertx.core.http.HttpServerOptions; //导入依赖的package包/类
private HttpServerOptions createOptions() {
Integer port = applicationConfiguration.getHttpPort();
logger.info("Starting HTTP server on port: {}", port);
HttpServerOptions options = new HttpServerOptions();
options.setLogActivity(true);
options.setHost("localhost");
options.setPort(port);
return options;
}