π¦ Learning Rust web servers with Axum & SQLx (Twitch live stream)
In this video, we explored the Axum web framework for the Rust programming language.
This is a follow-up to our previous live stream where we built a simple REST API that allows us to create and store simple textual notes in memory.
You can watch that episode here: https://youtu.be/Igajh2Vliog
In this episode, we improved the state management of our server by using Axum State extractor (https://docs.rs/axum/latest/axum/#sharing-state-with-handlers) and we added persistence on a SQLite database using the sqlx crate (https://github.com/launchbadge/sqlx).
The code is available here: https://github.com/lmammino/trying-axum
Chapters:
00:00:00 Intro
00:01:33 Reviewing the Axum documentation
00:02:18 Refactoring state with the State extractor
00:21:39 Our alternative approach to return Error responses (using Enums)
00:25:44 Looking at sqlx and setting it up in our project
00:37:00 A sample query with sqlx
00:57:00 Setting up our database with migrations through the CLI helper
01:01:28 Updating our code to use SQLite as a data storage
01:18:40 Testing our changes
01:20:40 Wrap up
To see the next episodes live check out our Twitch channel: https://twitch.tv/loige
#rust #Axum #sqlx