@@ -0,0 +1,2054 @@
+package de.springbootbuch.reactive.watchednow;%0A%0Aimport java.util.concurrent.CountDownLatch;%0Aimport static org.springframework.http.HttpMethod.GET;%0Aimport org.springframework.http.server.reactive.HttpHandler;%0Aimport org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;%0Aimport org.springframework.web.reactive.function.server.HandlerFunction;%0Aimport static org.springframework.web.reactive.function.server.RequestPredicates.GET;%0Aimport org.springframework.web.reactive.function.server.RouterFunction;%0Aimport org.springframework.web.reactive.function.server.RouterFunctions;%0Aimport org.springframework.web.reactive.function.server.ServerResponse;%0Aimport static org.springframework.web.reactive.function.server.ServerResponse.ok;%0Aimport reactor.core.publisher.Mono;%0Aimport reactor.ipc.netty.http.server.HttpServer;%0A%0A/**%0A * Part of springbootbuch.de.%0A *%0A * @author Michael J. Simons%0A * @author @rotnroll666%0A */%0Apublic class DemoFunctionalProgrammingModel %7B%0A%09public static void main(String...a) %7B%0A%0A%09%09HandlerFunction%3CServerResponse%3E helloWorld =%0A%09%09%09request -%3E ServerResponse.ok().body(%0A%09%09%09%09Mono.just(%22Hello, World%22), String.class%0A%09%09%09);%0A%0A%0A%09%09RouterFunction%3CServerResponse%3E helloSpringRoute =%0A%09%09%09request -%3E  %7B%0A%09%09%09%09if(request.method() == GET &&%0A%09%09%09%09%09request.path().equals(%22/hellospring%22)%0A%09%09%09%09) %7B%0A%09%09%09%09%09return Mono.just(r -%3E%0A%09%09%09%09%09%09ok().body(%0A%09%09%09%09%09%09%09Mono.just(%22Functional Spring%22),%0A%09%09%09%09%09%09%09String.class%0A%09%09%09%09%09%09)%0A%09%09%09%09%09);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09return Mono.empty();%0A%09%09%09%09%7D%0A%09%09%09%7D;%0A%0A%09%09RouterFunction%3CServerResponse%3E helloWorldRoute =%0A%09%09%09RouterFunctions.route(%0A%09%09%09%09GET(%22/helloworld%22), helloWorld);%0A%0A%09%09RouterFunction routes = helloSpringRoute%0A%09%09%09.and(helloWorldRoute);%0A%0A%09%09HttpHandler httpHandler = RouterFunctions%0A%09%09%09.toHttpHandler(routes);%0A%09%09HttpServer.create(8080)%0A%09%09%09.newHandler(new ReactorHttpHandlerAdapter(httpHandler))%0A%09%09%09.block();%0A%0A%09%09CountDownLatch latch = new CountDownLatch(1);%0A%09%09Thread awaitThread = new Thread(() -%3E %7B%0A%09%09%09try %7B%0A%09%09%09%09latch.await();%0A%09%09%09%7D catch (InterruptedException ex) %7B%0A%09%09%09%7D%0A%0A%09%09%7D);%0A%09%09awaitThread.setDaemon(false);%0A%09%09awaitThread.start();%0A%09%7D%0A%7D

Add introduction to funcitonal model