Skip to content

This project marks my first adventure into Rust and Actix web, aiming to create a simple REST API for managing user data. By Using the power of Actix web and connecting seamlessly with MongoDB as the backend database, this project highlights the core features of Actix web and walks through the step-by-step implementation of basic CRUD operation.

Notifications You must be signed in to change notification settings

Lakshaybogal/rust-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actix Web User Management API

Introduction

This Actix web application serves as my first project in Rust using Actix web. It provides a simple REST API for managing user data and utilizes MongoDB as the backend database. The project aims to showcase the basic functionalities of Actix web, including handling HTTP requests, working with MongoDB, and implementing CRUD operations.

Prerequisites

  • Ensure that MongoDB is installed and running.
  • Set the required environment variables (HOST_URL and DATABASE_URL) before running the application.

Endpoints

  1. GET /

    • Description: Displays a welcome message.
    • Example: curl http://localhost:8080/
  2. POST /add_user

    • Description: Adds a new user to the database.
    • Request Format: JSON with username and email fields.
    • Example:
      curl -X POST -H "Content-Type: application/json" -d '{"username": "John", "email": "john@example.com"}' http://localhost:8080/add_user
  3. GET /get_user/{email}

    • Description: Retrieves user details based on the provided email.
    • Example: curl http://localhost:8080/get_user/john@example.com
  4. PUT /update_user/{email}

    • Description: Updates user information based on the provided email.
    • Request Format: JSON with username and email fields.
    • Example:
      curl -X PUT -H "Content-Type: application/json" -d '{"username": "John Doe", "email": "john@example.com"}' http://localhost:8080/update_user/john@example.com
  5. DELETE /delete_user/{email}

    • Description: Deletes a user based on the provided email.
    • Example: curl -X DELETE http://localhost:8080/delete_user/john@example.com

Note

  • This project is my first exploration of Rust and Actix web.
  • It demonstrates fundamental Actix web features and MongoDB integration.
  • Ensure that the provided environment variables (HOST_URL and DATABASE_URL) are correctly set.
  • Replace placeholders in the examples with actual data.

About

This project marks my first adventure into Rust and Actix web, aiming to create a simple REST API for managing user data. By Using the power of Actix web and connecting seamlessly with MongoDB as the backend database, this project highlights the core features of Actix web and walks through the step-by-step implementation of basic CRUD operation.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages