Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions examples/webserver/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
##WebServer Basic Example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need spaces after the #.
See

Image


This example demonstrates a minimal Helidon WebServer application that starts an HTTP server and exposes simple routes.

##Project Structure

```
webserver-basic/
├── src
│ └── main
│ └── java
│ └── io/helidon/examples/webserver/basic/
│ ├── Main.java
│ └── GreetService.java
├── pom.xml
└── README.md
```
##Build
Use Maven to compile the project:

```shell
mvn clean install
```

##Run
Start the WebServer using:
```shell
java -jar target/webserver-basic.jar
```

The server will start on the default port (8080) unless configured otherwise.

##Exercise the Application
After the application is running, you can call the available endpoints:

Root endpoint
```shell
curl -X GET http://localhost:8080
```

Greet endpoint
```shell
curl -X GET http://localhost:8080/greet
```

Personalized greeting
```shell
curl -X GET http://localhost:8080/greet/{name}
```

This will return:
```json
{
"message": "Hello {name}!"
}
```

Update the greeting
```shell
curl -X PUT -H "Content-Type: application/json" \
-d '{"greeting": "Hola"}' \
http://localhost:8080/greet/greeting
```

##Notes

This example follows the standard Helidon project layout.

For more advanced server features, refer to other examples in the repository.