Member-only story
How to Write a REST API Using Rust and Axum Framework
With Postgres connection pooling

This article will demonstrate writing a REST API from scratch using Rust and Axum framework. I’ll show you how to set up a production-ready Rust Workspace, plan the API and add request validations, and finally some samples for logging, database handling, and error responses.
In the past, I spent quite some time searching for a nice web framework in Rust. Played quite a bit with Actix Web, Rocket, and Axum. But in the end, I chose Axum because it has nice semantics and Straightforward programming paradigms. I couldn’t find a lot of documentation around Axum, but finally figured out how to structure and write a basic REST API using this framework.
Before creating our project and start coding, i want to give a brief overview of the requirements and Business Context.
This tutorial is a part of an entire REST API framework i’m planning to build over time. Please don’t forget to subscribe and follow me for regular updates if it helps you in any way!
Business Context
We’re going to develop the CREATE API
for an experimentation platform. Online Experimentation or most known as AB testing, allows organizations to test features and experiences on their consumers.