content: package com.example;
  
  import org.springframework.http.server.reactive.HttpHandler;
  import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
  import org.springframework.web.reactive.function.server.HandlerFunction;
  import org.springframework.web.reactive.function.server.RouterFunction;
  import org.springframework.web.reactive.function.server.RouterFunctions;
  import org.springframework.web.reactive.function.server.ServerResponse;
  import reactor.netty.http.server.HttpServer;
  
  import static org.springframework.http.MediaType.APPLICATION_JSON;
  import static org.springframework.web.reactive.function.BodyInserters.fromObject;
  import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
  import static org.springframework.web.reactive.function.server.RouterFunctions.route;
  import static org.springframework.web.reactive.function.server.ServerResponse.ok;
  
  public class FunctionalWebApplication {
  
      static RouterFunction getRouter() {
          HandlerFunction<ServerResponse> hello = request -> ok().body(fromObject("Hello"));
  
          return
              route(
                  GET("/"), hello)
              .andRoute(
                  GET("/json"), req -> ok().contentType(APPLICATION_JSON).body(fromObject(new Hello("world"))));
      }
  
      public static void main(String[] args) throws InterruptedException {
  
          RouterFunction router = getRouter();
  
          HttpHandler httpHandler = RouterFunctions.toHttpHandler(router);
  
          HttpServer
                  .create()
                  .port(8080)
                  .handle(new ReactorHttpHandlerAdapter(httpHandler))
                  .bindNow();
  
          Thread.currentThread().join();
      }
  }
  