RESTful Rust is straightforward REST API example written in Rust. It shows how to implement and test GET, POST, PUT and DELETE methods with amazing Warp web server framework.
To run the project locally:
- install rustup by following the instructions
- add clippy (collection of lints) and rustfmt (code formatter) by running
rustup component add clippy
andrustup component add rustfmt
accordingly - clone this repository
git clone https://github.com/blurbyte/restful-rust.git
- to start an API enter project's directory and run
cargo run
- run tests with
cargo test
- lint code with
cargo clippy
and format it withcargo fmt
- run
cargo build --release
command to generate single optimized binary
Dependency | Description |
---|---|
warp | Composable web server framework with powerful filters system |
serde | Library for serializing and deserializing data structures |
chrono | Date and time utilities |
log + pretty_env_logger | Simple logger (by default enabled in debug mode) |
List of API routes with associated REST verbs:
- http://localhost:8080/games - GET, POST
- http://localhost:8080/games/:id - PUT, DELETE
Nowadays there are many great tools which make testing API easy, such as Postman or Insomnia.
Just enter one of the available endpoints with appropriate HTTP method selected:
And watch a console / terminal for detailed logs: