maestroh1git / rest-api-hyper

Hyper is not the most convenient way to build an API as it doesn’t provide out-of-the-box solutions such as detecting parameters. Interestingly enough, other web server frameworks such as warp are built on Hyper.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust API Using Hyper

This is an example of how to build a Rust API using Hyper with Tokio, to generate a simple API containing the following endpoints

  • GET /cars = to fetch all cars
  • GET /cars/:id = to fetch a specific car
  • POST /cars = to create a new car

The car records are not stored in a database but rather in memory as the main reason of this project is for understanding purposes. If you need a thorough explanation, check out the article rust-api-using-hyper

Requirements

This codebase uses Rust programming langauge. Hence, you must have Rust properly installed in your machine if you want to run the code.

Refer to https://www.rust-lang.org/tools/install to setup Rust in your local machine.

Do you want to run the code?

Clone this repo to your local machine. Open the terminal and run the command cargo run command.

About

Hyper is not the most convenient way to build an API as it doesn’t provide out-of-the-box solutions such as detecting parameters. Interestingly enough, other web server frameworks such as warp are built on Hyper.


Languages

Language:Rust 100.0%