|
| 1 | +# Basic Helidon SE WebServer Example |
| 2 | + |
| 3 | +This example demonstrates the simplest possible Helidon SE WebServer application. |
| 4 | +It shows how to start a server, register routing rules, and return basic responses. |
| 5 | + |
| 6 | +Helidon SE is a lightweight, reactive, microframework for building fast Java microservices. |
| 7 | +This example is an ideal starting point for beginners learning Helidon SE. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## 📘 What This Example Demonstrates |
| 12 | + |
| 13 | +### ✔ 1. Starting a Helidon WebServer |
| 14 | +Shows how to bootstrap the WebServer using: |
| 15 | + |
| 16 | +```java |
| 17 | +WebServer webServer = WebServer.builder(routing).port(8080).build(); |
| 18 | +✔ 2. Basic Routing |
| 19 | + |
| 20 | +Demonstrates registering simple GET endpoints such as: |
| 21 | + |
| 22 | +GET /simple-greet |
| 23 | + |
| 24 | +GET /greet/{name} |
| 25 | + |
| 26 | +✔ 3. Working With JSON |
| 27 | + |
| 28 | +Responds with a JSON payload using Helidon’s built-in media support. |
| 29 | + |
| 30 | +✔ 4. Logging Configuration |
| 31 | + |
| 32 | +Shows how logging.properties is used to configure logging behavior. |
| 33 | + |
| 34 | +✔ 5. Integration Testing |
| 35 | + |
| 36 | +The BasicRoutingTest.java file demonstrates: |
| 37 | + |
| 38 | +starting the server programmatically for testing |
| 39 | + |
| 40 | +invoking endpoints |
| 41 | + |
| 42 | +validating response codes and content |
| 43 | +🗂 Project Structure |
| 44 | +basic/ |
| 45 | + ├── pom.xml |
| 46 | + └── src |
| 47 | + ├── main |
| 48 | + │ ├── java/io/helidon/examples/webserver/basic/BasicMain.java |
| 49 | + │ └── resources/logging.properties |
| 50 | + └── test |
| 51 | + └── java/io/helidon/examples/webserver/basic/BasicRoutingTest.java |
| 52 | + |
| 53 | +▶️ How to Run |
| 54 | + |
| 55 | +Run using Maven: |
| 56 | + |
| 57 | +mvn -q exec:java |
| 58 | + |
| 59 | + |
| 60 | +The server will start on: |
| 61 | + |
| 62 | +http://localhost:8080 |
| 63 | + |
| 64 | +📡 Available Endpoints |
| 65 | +Method Path Description |
| 66 | +GET /simple-greet Returns a basic greeting |
| 67 | +GET /greet/{name} Returns “Hello {name}!” text |
| 68 | + |
| 69 | +Example: |
| 70 | + |
| 71 | +curl http://localhost:8080/simple-greet |
| 72 | +curl http://localhost:8080/greet/Naveen |
| 73 | + |
| 74 | +🧪 Running Tests |
| 75 | +mvn test |
| 76 | + |
| 77 | + |
| 78 | +The test suite validates: |
| 79 | + |
| 80 | +server startup |
| 81 | + |
| 82 | +routing behavior |
| 83 | + |
| 84 | +responses and status codes |
| 85 | + |
| 86 | +🎯 Why This Example Is Useful |
| 87 | + |
| 88 | +Provides the smallest possible working Helidon WebServer project |
| 89 | + |
| 90 | +Ideal for new users exploring Helidon SE routing, JSON responses, and server startup |
| 91 | + |
| 92 | +Demonstrates best practices for organizing code and tests |
| 93 | + |
| 94 | +Helps contributors understand Helidon’s reactive architecture |
0 commit comments