This project provides simple and scalable template for building RESTful APIs using Rust. It is designed to streamline the development of APIs by offering a well-structured starting point for your projects.
This template is based on multiple libraries:
- warp: composable web framework
- log: logging information (and currently with colog as implementation)
- dotenv: read environment variables from .env
- diesel (postgres): ORM for Postgres databases (can be easily adapted to work with sqlite and MySQL)
- Rust: Ensure you have Rust installed. You can install it from rustup.rs.
- Cargo: Cargo, the Rust package manager, should be installed with Rust.
-
Clone the repository:
git clone https://github.com/ecivini/rust-api-template.git cd rust-api-template
-
Build the project:
cargo build
-
Run the application:
cargo run
Configuration is handled via environment variables. You can set up a .env
file at the root of the project to manage your configurations:
# Server configuration
SERVER_HOST=0.0.0.0
SERVER_PORT=3000
# Database
DATABASE_URL=
Contributions are welcome! Please open an issue or submit a pull request with any improvements, bug fixes, or new features.
This project is licensed under the Apache 2.0 License. See the LICENSE.md file for details.