Java Code Examples for reactor.netty.http.server.HttpServer#create()

The following examples show how to use reactor.netty.http.server.HttpServer#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RSocketNettyReactiveWebServerFactory.java    From spring-boot-rsocket with Apache License 2.0 6 votes vote down vote up
private HttpServer createHttpServer() {
	HttpServer server = HttpServer.create();
	if (this.resourceFactory != null) {
		LoopResources resources = this.resourceFactory.getLoopResources();
		Assert.notNull(resources,
				"No LoopResources: is ReactorResourceFactory not initialized yet?");
		server = server.tcpConfiguration((tcpServer) -> tcpServer.runOn(resources)
				.addressSupplier(this::getListenAddress));
	}
	else {
		server = server.tcpConfiguration(
				(tcpServer) -> tcpServer.addressSupplier(this::getListenAddress));
	}
	if (getSsl() != null && getSsl().isEnabled()) {
		SslServerCustomizer sslServerCustomizer = new SslServerCustomizer(getSsl(),
				getHttp2(), getSslStoreProvider());
		server = sslServerCustomizer.apply(server);
	}
	if (getCompression() != null && getCompression().getEnabled()) {
		CompressionCustomizer compressionCustomizer = new CompressionCustomizer(
				getCompression());
		server = compressionCustomizer.apply(server);
	}
	server = server.protocol(listProtocols()).forwarded(this.useForwardHeaders);
	return applyCustomizers(server);
}
 
Example 2
Source File: HttpRedirectTest.java    From reactor-netty with Apache License 2.0 5 votes vote down vote up
@Test
public void testHttpServerWithDomainSockets() throws Exception {
	HttpServer server = HttpServer.create();
	HttpClient client = HttpClient.create();

	doTestHttpServerWithDomainSockets(server, client);

	SelfSignedCertificate cert = new SelfSignedCertificate();
	SslContextBuilder serverCtx = SslContextBuilder.forServer(cert.certificate(), cert.privateKey());
	SslContextBuilder clientCtx = SslContextBuilder.forClient()
	                                               .trustManager(InsecureTrustManagerFactory.INSTANCE);
	doTestHttpServerWithDomainSockets(
			server.protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(serverCtx)),
			client.protocol(HttpProtocol.H2).secure(spec -> spec.sslContext(clientCtx)));
}
 
Example 3
Source File: WebsocketRouteTransportTest.java    From rsocket-java with Apache License 2.0 5 votes vote down vote up
@DisplayName("starts server")
@Test
void start() {
  WebsocketRouteTransport serverTransport =
      new WebsocketRouteTransport(HttpServer.create(), routes -> {}, "/test-path");

  serverTransport
      .start(duplexConnection -> Mono.empty())
      .as(StepVerifier::create)
      .expectNextCount(1)
      .verifyComplete();
}
 
Example 4
Source File: SpringSecurity5Application.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public DisposableServer disposableServer(ApplicationContext context) {
    HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
            .build();
    ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
    HttpServer httpServer = HttpServer.create();
    httpServer.host("localhost");
    httpServer.port(8080);
    return httpServer.handle(adapter).bindNow();
}
 
Example 5
Source File: WebsocketRouteTransportTest.java    From rsocket-java with Apache License 2.0 4 votes vote down vote up
@DisplayName("creates server")
@Test
void constructor() {
  new WebsocketRouteTransport(HttpServer.create(), routes -> {}, "/test-path");
}