|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2021, 2022 Oracle and/or its affiliates. |
| 2 | + * Copyright (c) 2021, 2023 Oracle and/or its affiliates. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.util.concurrent.ExecutorService;
|
20 | 20 | import java.util.concurrent.Executors;
|
21 | 21 | import java.util.concurrent.Future;
|
22 |
| -import java.util.concurrent.TimeUnit; |
23 | 22 |
|
24 | 23 | import io.helidon.common.context.Context;
|
25 | 24 | import io.helidon.common.context.Contexts;
|
26 | 25 | import io.helidon.logging.common.HelidonMdc;
|
27 |
| -import io.helidon.reactive.webserver.Routing; |
28 |
| -import io.helidon.reactive.webserver.WebServer; |
| 26 | +import io.helidon.nima.webserver.WebServer; |
| 27 | +import io.helidon.nima.webserver.http.HttpRouting; |
29 | 28 |
|
30 | 29 | import ch.qos.logback.classic.LoggerContext;
|
31 | 30 | import ch.qos.logback.classic.joran.JoranConfigurator;
|
@@ -60,20 +59,20 @@ public static void main(String[] args) {
|
60 | 59 | // done by the webserver
|
61 | 60 | Contexts.runInContext(Context.create(), Main::logging);
|
62 | 61 |
|
63 |
| - WebServer.builder() |
64 |
| - .routing(Routing.builder() |
65 |
| - .get("/", (req, res) -> { |
66 |
| - HelidonMdc.set("name", String.valueOf(req.requestId())); |
67 |
| - LOGGER.debug("Debug message to show runtime reloading works"); |
68 |
| - LOGGER.info("Running in webserver, id:"); |
69 |
| - res.send("Hello") |
70 |
| - .forSingle(ignored -> LOGGER.debug("Response sent")); |
71 |
| - }) |
72 |
| - .build()) |
| 62 | + WebServer server = WebServer.builder() |
73 | 63 | .port(8080)
|
74 |
| - .build() |
75 |
| - .start() |
76 |
| - .await(10, TimeUnit.SECONDS); |
| 64 | + .routing(Main::routing) |
| 65 | + .start(); |
| 66 | + } |
| 67 | + |
| 68 | + private static void routing(HttpRouting.Builder routing) { |
| 69 | + routing.get("/", (req, res) -> { |
| 70 | + HelidonMdc.set("name", String.valueOf(req.id())); |
| 71 | + LOGGER.debug("Debug message to show runtime reloading works"); |
| 72 | + LOGGER.info("Running in webserver, id:"); |
| 73 | + res.send("Hello"); |
| 74 | + LOGGER.debug("Response sent"); |
| 75 | + }); |
77 | 76 | }
|
78 | 77 |
|
79 | 78 | private static void setupLogging() {
|
|
0 commit comments