rust-rocket-sample is a fully working CRUD REST API example built using Rust and the Rocket framework. It demonstrates various features such as connecting to MongoDB, handling errors, implementing CORS, and generating API documentation using okapi. It also provides test codes to verify the functionality of the API endpoints.
To run the rust-rocket-sample project, follow these steps:
.env file and add the following environment variables:
MONGO_URI: MongoDB connection URI.
MONGO_DB_NAME: Name of the MongoDB database.
API_KEY: API key for securing the REST API endpoints.
Build and run the project in debug mode:
Build and run the project in release mode:
cargo build --release
cargo run --release
To run the unit tests, use the following command:
rust-rocket-sample is a comprehensive example of building a CRUD REST API using Rust and the Rocket framework. It covers various features including MongoDB integration, error handling, fairings, request guards, and API documentation generation. The provided test codes ensure the functionality of the API endpoints.