Skip to content

fromscratchcode/rust-api-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Your First REST API in Rust

Getting started

Install Rust using https://rustup.rs/.

Clone this repo and run the starter app:

git clone https://github.com/fromscratchcode/rust-api-workshop.git
cd rust-api-workshop/starter
cargo run

The starter directory contains the minimal version we’ll build from. The completed version lives in the solution directory.

In a separate shell, verify the server is running:

curl http://localhost:7878/health

You should see:

{"status": "OK"}

REST API

We'll start from a minimal Axum server and progressively implement each of these routes.

  • GET /users
  • POST /users
  • GET /users/{id}
  • PUT /users/{id}
  • DELETE /users/{id}

Recreate this project from scratch (Optional)

cargo new rest-api
cd rest-api

cargo add axum
cargo add tokio --features full
cargo add serde --features derive
cargo add serde_json

License

The software is granted under the terms of the MIT License. For details see the file LICENSE included with the source distribution. All copyrights are owned by their respective authors.

About

Build your first REST API in Rust using Axum.

Resources

License

Stars

Watchers

Forks

Languages