This project is a simple Rust Actix Web server that demonstrates how to:
- Create routes with GET and POST.
- Store users in an in-memory database using
HashMapwrapped withArc<Mutex<...>>. - Handle JSON serialization and deserialization with
serde.
GET /greet/{id}– Returns a greeting for the given user ID.POST /users– Creates a new user and stores it in memory.
src/
├── main.rs # Entry point of the Actix Web server
Cargo.toml # Project dependencies and metadata
README.md # Project documentation
- Rust (latest stable recommended)
- Cargo (comes with Rust)
git clone https://github.com/your-username/actix-web-server.git
cd actix-web-serverRun the Server
cargo runThe server will start at:
http://127.0.0.1:8080API Endpoints
Request
GET /greet/{id}Example
curl http://127.0.0.1:8080/greet/1
Response
{
"message": "Hello, User 1!"
}Request
POST /users
Content-Type: application/jsonNotes
The database is in-memory only (cleared when the server restarts). This is a minimal example for learning purposes.