In this course, we'll create a REST API server in Rust to represent a bookstore. This bookstore would allow us to add books and authors.
Using this system, we'll be able to:
Create, list, update and delete authors
Create, list, update and delete books
Associate and disassociate books and authors
List all books by a particular author
We'll learn how to:
Create a new Rust project using cargo
Build and run our Rust project
Add crates and enable crate features
In this course, we'll create a REST API server in Rust to represent a bookstore. This bookstore would allow us to add books and authors.
Using this system, we'll be able to:
Create, list, update and delete authors
Create, list, update and delete books
Associate and disassociate books and authors
List all books by a particular author
We'll learn how to:
Create a new Rust project using cargo
Build and run our Rust project
Add crates and enable crate features
We'll learn about basic API concepts such:
Routing and HTTP methods
Extracting data from HTTP requests
Interacting with the database to query and insert data
Creating user accounts
Authentication using JWT
Creating and using relationships between models to query and list associated data
Along with these concepts, we'll learn how to:
Handle incoming (request) and outgoing (response) data in a type safe way
Handle CORS
Create and run database migrations
Create one-to-many database relationships
Create entities from database tables
We'll have a bonus lecture at the end to learn how to Dockerize our API server to deploy and run it anywhere.
We'll be using the following crates:
Rocket: a web framework for Rust that makes it simple to write fast, secure web applications without sacrificing flexibility, usability, or type safety.
SeaORM: is a relational ORM to help you build web services in Rust.
jsonwebtoken to create and decode JWTs in a strongly typed way.
serde_json for serializing and deserializing Rust data structures efficiently and generically.
Let's see if we understand the basics of setting up a new Rust project.
Rocket website: rocket.rs
Add the following to your Cargo.toml under [dependencies]:
rocket = { version = "^0.5.0-rc.2", features = ["json"] }
main.rs
#[macro_use] extern crate rocket;
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![index])
}
Verified partner policies & purchase protections
Free preview video lectures available for all courses; optional 7-day free trial on Personal Plan subscriptions (cancel before trial ends to avoid conversion).
30-day money-back guarantee on all eligible individual course purchases (provided course content has not been substantially consumed or downloaded). Subscription fees are non-refundable once billed.
Lifetime access to purchased individual courses and future updates, verifiable certificate of completion, and direct student Q&A forums.
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.