|
| 1 | +🚀 Helidon WebServer – Basic Example |
| 2 | + |
| 3 | +This example demonstrates the simplest possible Helidon SE WebServer application. |
| 4 | +It shows how to start a server, define basic routing, handle HTTP requests, and return responses. |
| 5 | + |
| 6 | +This is a good starting point for understanding how Helidon SE applications are structured. |
| 7 | + |
| 8 | +📂 Project Structure |
| 9 | +basic/ |
| 10 | + ├── pom.xml |
| 11 | + └── src |
| 12 | + ├── main |
| 13 | + │ ├── java/io/helidon/examples/webserver/basic/BasicMain.java |
| 14 | + │ └── resources/logging.properties |
| 15 | + └── test |
| 16 | + └── java/io/helidon/examples/webserver/basic/ |
| 17 | + ├── AbstractBasicRoutingTest.java |
| 18 | + ├── BasicRoutingIT.java |
| 19 | + └── BasicRoutingTest.java |
| 20 | + |
| 21 | +🧠 What This Example Shows |
| 22 | +✔ Start a WebServer |
| 23 | + |
| 24 | +The example configures and starts a Helidon SE WebServer on a selected port. |
| 25 | + |
| 26 | +✔ Define Basic Routing |
| 27 | + |
| 28 | +It demonstrates simple routing, including: |
| 29 | + |
| 30 | +Returning plain text responses |
| 31 | + |
| 32 | +Handling HTTP GET endpoints |
| 33 | + |
| 34 | +Using routing builders |
| 35 | + |
| 36 | +✔ Logging Configuration |
| 37 | + |
| 38 | +logging.properties shows how Helidon configures Java Util Logging (JUL). |
| 39 | + |
| 40 | +✔ Tests Included |
| 41 | + |
| 42 | +The example contains: |
| 43 | + |
| 44 | +Unit tests |
| 45 | + |
| 46 | +Integration tests (running an actual WebServer instance) |
| 47 | + |
| 48 | +These tests help verify routing behavior automatically. |
| 49 | + |
| 50 | +▶️ How to Run |
| 51 | +Using Maven |
| 52 | + |
| 53 | +From the basic directory: |
| 54 | + |
| 55 | +mvn package |
| 56 | +java -jar target/basic.jar |
| 57 | + |
| 58 | + |
| 59 | +Server starts on the default port (usually 8080). |
| 60 | + |
| 61 | +You will see output like: |
| 62 | + |
| 63 | +WEB server started at http://localhost:8080 |
| 64 | + |
| 65 | +🔗 Example Endpoints |
| 66 | + |
| 67 | +Once the server is running, try: |
| 68 | + |
| 69 | +GET /greet |
| 70 | +curl http://localhost:8080/greet |
| 71 | + |
| 72 | + |
| 73 | +Response: |
| 74 | + |
| 75 | +Hello World! |
| 76 | + |
| 77 | + |
| 78 | +If routing includes path parameters, you may also test: |
| 79 | + |
| 80 | +GET /greet/{name} |
| 81 | +curl http://localhost:8080/greet/Naveen |
| 82 | + |
| 83 | + |
| 84 | +Example response: |
| 85 | + |
| 86 | +Hello Naveen! |
| 87 | + |
| 88 | +🧪 Run Tests |
| 89 | +mvn test |
| 90 | + |
| 91 | + |
| 92 | +This executes both: |
| 93 | + |
| 94 | +Unit tests |
| 95 | + |
| 96 | +Integration tests (start WebServer and verify responses) |
| 97 | + |
| 98 | +📘 Useful to Learn |
| 99 | + |
| 100 | +This example helps new users understand: |
| 101 | + |
| 102 | +How to create a minimal Helidon SE service |
| 103 | + |
| 104 | +How routing works |
| 105 | + |
| 106 | +How requests and responses are handled |
| 107 | + |
| 108 | +How Helidon SE applications are structured |
| 109 | + |
| 110 | +How to write integration tests for WebServer applications |
0 commit comments