Skip to content

Aksshay88/rust-actix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actix Web Server Example

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 HashMap wrapped with Arc<Mutex<...>>.
  • Handle JSON serialization and deserialization with serde.

Features

  • GET /greet/{id} – Returns a greeting for the given user ID.
  • POST /users – Creates a new user and stores it in memory.

Project Structure

src/
├── main.rs # Entry point of the Actix Web server
Cargo.toml # Project dependencies and metadata
README.md  # Project documentation

Prerequisites

  • Rust (latest stable recommended)
  • Cargo (comes with Rust)

Getting Started

1. Clone the Repository

git clone https://github.com/your-username/actix-web-server.git
cd actix-web-server

Run the Server

cargo run

The server will start at:

http://127.0.0.1:8080

API Endpoints

Request

GET /greet/{id}

Example

curl http://127.0.0.1:8080/greet/1

Response

{
  "message": "Hello, User 1!"
}

2. Create a New User

Request

POST /users

Content-Type: application/json

Notes

The database is in-memory only (cleared when the server restarts). This is a minimal example for learning purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published