Skip to content

integrationninjas/rust-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-app

User CRUD API

Overview

This is a simple CRUD API for managing users using Actix Web and MongoDB.

Prerequisites

  • Rust installed
  • MongoDB running
  • Docker (optional, for containerization)

Running the API

Locally

Create a .env file with:

MONGO_URI=mongodb://localhost:27017
DATABASE_NAME=my_database

Then, run:

cargo run

Using Docker

Build and run the container:

docker build -t rust-app .
docker run -p 5050:3030 rust-app

API Endpoints

1. Get All Users

GET /users

curl --location 'http://localhost:5050/users'

2. Create a New User

POST /users

curl --location 'http://localhost:5050/users' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "John Doe",
    "email": "john@example.com",
    "age": 30
}'

3. Update a User

PUT /users/{user-id}

curl --location --request PUT 'http://localhost:5050/users/<user-id>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "John Doe",
    "email": "john.doe@example.com",
    "age": 37
}'

4. Delete a User

DELETE /users/{user-id}

curl --location --request DELETE 'http://localhost:5050/users/<user-id>'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages