restful-rust
restful-rust copied to clipboard
Super simple RESTful API example in Rust.
RESTful Rust
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.
Getting started
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 clippyandrustup component add rustfmtaccordingly - 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 clippyand format it withcargo fmt - run
cargo build --releasecommand to generate single optimized binary
Dependencies overview
| 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) |
Available endpoints
List of API routes with associated REST verbs:
- http://localhost:8080/games - GET, POST
- http://localhost:8080/games/:id - PUT, DELETE
Testing RESTful API
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: