An HTTP server build with Warp light-weight framework that provides CRUD operations with MongoDB.
- HTTP Method: POST
- URL Path:
http://localhost:8080/book
- Description: Create a new book by providing book details in the request body.
- HTTP Method: GET
- URL Path:
http://localhost:8080/books
- Description: Retrieve a list of all books.
- HTTP Method: PUT
- URL Path:
http://localhost:8080/book/{id}
- Description: Edit a specific book by providing its ID in the URL path.
- HTTP Method: DELETE
- URL Path:
http://localhost:8080/book/{id}
- Description: Delete a book by providing its ID in the URL path.
Before you begin, ensure you have met the following requirements:
- Rust and Cargo installed. Check the official rust website.
- Docker Compose. You can download it from the official docker website.
- Start docker containers:
docker-compose up -d
- Run unit-tests with:
cargo test --bin rust-mongo -- --nocapture
- Run integration tests with:
cargo test --test integration_test -- --nocapture
- Build the project with:
cargo build
- Run the project with:
cargo run
- Start docker containers:
docker-compose up -d
- Run the project:
cargo run
- Create book:
cd script/ && ./create_book.sh
- Fetch books:
cd script/ && ./fetch_books.sh
- Edit book using its MongoDB generated ID:
cd script/ && ./edit_book.sh
- Delete book using its MongoDB generated ID:
cd script/ && ./delete_book.sh
docker-compose up -d
--> start docker containersdocker ps
--> shows all running containersdocker exec -it rust-mongo bash
--> open the Bash shell inside the running MongoDB containermongod --version
--> verify mongo servermongosh
--> connect to the MongoDB servershow dbs
--> list all existing databasesuse library
--> switch to the library databse which we use in this applicationdb.books.find()
--> query all documents inside the books collection