use of reactor.netty.DisposableServer in project spring-framework by spring-projects.
the class ReactorHttpsServer method startInternal.
@Override
protected void startInternal() {
DisposableServer server = this.reactorServer.handle(this.reactorHandler).bind().block();
setPort(((InetSocketAddress) server.address()).getPort());
this.serverRef.set(server);
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class ITTracingHttpClientDecoratorTest method currentSpanVisibleToUserHandler.
@Test
@SuppressWarnings("try")
public void currentSpanVisibleToUserHandler() {
AtomicReference<HttpHeaders> headers = new AtomicReference<>();
DisposableServer disposableServer = null;
TraceContext parent = newTraceContext(SamplingFlags.SAMPLED);
try (Scope scope = currentTraceContext.newScope(parent)) {
disposableServer = HttpServer.create().port(0).handle((req, res) -> {
headers.set(req.requestHeaders());
return res.sendString(Mono.just("test"));
}).bindNow();
client.port(disposableServer.port()).request(HttpMethod.GET).uri("/").send((req, out) -> {
req.header("test-id", currentTraceContext.get().traceIdString());
return out;
}).responseContent().aggregate().block(Duration.ofSeconds(30));
assertThat(headers.get()).isNotNull();
assertThat(headers.get().get("x-b3-traceId")).isEqualTo(headers.get().get("test-id"));
} finally {
if (disposableServer != null) {
disposableServer.disposeNow();
}
}
testSpanHandler.takeRemoteSpan(CLIENT);
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = HttpServer.create().metrics(true, // <1>
CustomHttpServerMetricsRecorder::new).route(r -> r.get("/stream/{n}", (req, res) -> res.sendString(Mono.just(req.param("n")))).get("/bytes/{n}", (req, res) -> res.sendString(Mono.just(req.param("n"))))).bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = HttpServer.create().httpFormDecoder(// <1>
builder -> builder.maxInMemorySize(0)).route(routes -> routes.post("/multipart", (request, response) -> response.sendString(// <2>
request.receiveForm(builder -> builder.maxInMemorySize(256)).flatMap(data -> Mono.just('[' + data.getName() + ']'))))).bindNow();
server.onDispose().block();
}
use of reactor.netty.DisposableServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
DisposableServer server = HttpServer.create().route(routes -> routes.get("/{param}", (request, response) -> {
if (request.requestHeaders().contains("Some-Header")) {
return response.sendString(Mono.just(request.param("param")));
}
return response.sendNotFound();
})).bindNow();
server.onDispose().block();
}
Aggregations