Share E-Book

Beginning Axum - Learning Modern Web Development With Rust (for memsa memsa) (Indo Yoon)(Z-Library)

Author Indo Yoon

rust
Language English

No Description

Format PDF
Size 8.3 MB
9
Views
0
Downloads
0.00
Total Donations
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
Indo Yoon Beginning Axum Learning Modern Web Development With Rust
Page 3
Indo Yoon Seoul, Korea (Republic of) ISBN 979-8-8688-2630-6 e-ISBN 979-8-8688-2631-3 https://doi.org/10.1007/979-8-8688-2631-3 © Indo Yoon 2026 This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use. The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations. Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-
Page 4
SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm. comwww. springeronline. com, or visit . Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature. The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
Page 5
Introduction This book introduces Axum, a modern Rust web framework. Through practical code examples, you'll learn to build production-ready backend applications—from basic routing and database integration to middleware and real-time WebSocket communication. Whether you're new to Rust or an experienced developer exploring new frameworks, this book provides a hands-on path to mastering Axum.
Page 6
About This Book This book covers Axum, a Rust backend framework. Axum is developed by the Tokio project, Rust’s most prominent project, and is the fastest-growing Rust framework. Currently, no books specifically focus on the Axum framework, either domestically or internationally. We wrote this book to promote Axum, which has tremendous growth potential, and to help more people adopt it. We explain Axum’s unique user-friendly approach through actual code examples. We’ve focused on features essential in real-world development and structured the book so you can build a complete backend application simply by following along. We provide concise explanations of Rust programming basics and backend technologies while covering each functional component in detail, helping you naturally understand Axum’s architecture. Through this book, we hope you’ll fully experience the appeal of Rust and Axum, and we look forward to seeing many more projects adopt this powerful combination. Target Audience This book will be especially helpful for the following readers. Readers Who Want to Learn Rust If you want to learn Rust through this book, you’ll master core concepts and important syntax in each chapter. We cover many examples where you can actually apply each concept, giving you an opportunity to learn Rust quickly. Readers Who Want to Try a New Project If you’ve learned Rust and want to create your own project, especially web- related projects, this book is ideal. Since Axum actively utilizes Rust’s strength in asynchronous programming, you’ll get an opportunity to learn new things while reviewing Rust’s core concepts.
Page 7
Readers Who Want to Write a High-Performance Web Server This book covers various practical techniques including database configuration, middleware construction, and implementing Server-Sent Event (SSE) endpoints. Whether you’re building high-performance servers for work or side projects, this book will help you achieve your goals more quickly. Prerequisites We recommend having some background knowledge of Rust to read this book, though it’s not required. For readers encountering this content for the first time, we’ve included brief background information and related explanations at the beginning of each chapter. For Rust basics, familiarity with the following concepts is helpful. If you’re new to Rust, we recommend first studying Learning Rust by Comparing with Python (J-Pub, 2024), which clearly explains Rust’s fundamental syntax and concepts. Ownership: Ownership transfer/borrowing, references Asynchronous programming: Arc, Mutex, async/await (tokio knowledge is helpful but not required) Other: Structs, closures For backend server fundamentals, understanding the following is helpful. Don’t worry if you’re unfamiliar—we’ve included plenty of examples and detailed explanations to help you understand easily. Relational Database Management System (RDBMS): This book uses PostgreSQL. Experience with other relational databases (MySQL, MariaDB, etc.) transfers easily. SQL: Basic queries for table definition, data retrieval, and modification. HTTP: Concepts like query parameters, path parameters, and request bodies needed for REST API design.
Page 8
Book Structure Each chapter covers the following: Chapter 1: Introduces Rust backend development characteristics and performs environment setup for practice exercises. Chapter 2: Examines Axum’s core components—routing HTTP requests, processing query parameters and JSON bodies through Extractors, and sharing state across the app through State. Chapter 3: Integrates PostgreSQL with SeaORM, explores schema and migration management, completes all necessary endpoints, and modularizes the project. Chapter 4: Examines tower middleware essentials like logging, timeouts, and authentication and applies them to the application. Chapter 5: Explores WebSocket, a protocol for real-time bidirectional communication between clients and servers, and implements single- connection and multi-connection WebSocket handlers. Chapter 6: Builds a complete chat service project with SSE-based real- time messaging, a React frontend, automated testing, and Docker deployment. The book is structured for easy follow-along with code and screenshots. All code is available on GitHub. If you encounter problems or have questions, please use the repository’s Discussion section. Example code can be found at REST API example: https://github.com/Indosaram/axum- book-code Chat service example: https://github.com/Indosaram/axum-react-chat-app The Docker image built in Chapter 6 is available at https://hub.docker.com/repository/docker/indosar am/axum-chat-app/general.
Page 9
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub. For more detailed information, please visit https:// www. apress. com/ gp/ services/ source-code.
Page 10
Acknowledgments I am deeply grateful to my wife for her unwavering support and patience throughout the writing of this book. The countless late nights and weekends I spent at my desk were made possible only by her understanding, encouragement, and the extra responsibilities she quietly shouldered at home. This book would not exist without her.
Page 11
Table of Contents Chapter 1: Rust and Server Development 1. 1. Why Rust? 1. 1. 1. Advantages of Rust 1. 1. 2. Advantages of Developing Backends with Rust 1. 2. Rust Server Development Case Studies 1. 2. 1. Figma 1. 2. 2. Discord 1. 2. 3. Dropbox 1. 2. 4. npm 1. 3. Comparing Rust Backend Frameworks 1. 3. 1. Why You Should Use Axum 1. 4. Setting Up the Development Environment 1. 4. 1. Installing the Rust Toolchain 1. 4. 2. Installing and Setting Up Visual Studio Code 1. 4. 3. Creating a Project 1. 4. 4. Installing the PostgreSQL Database 1. 4. 5. Installing DBeaver 1. 4. 6. Installing API Testing Tools 1. 5. Reviewing Rust Core Concepts 1. 5. 1. Ownership 1. 5. 2. Ownership of Values 1. 5. 3. Returning Ownership 1. 5. 4. References and Borrowing Ownership
Page 12
1. 5. 5. Mutable References 1. 5. 6. Crates 1. 5. 7. Modules 1. 5. 8. Using Modules 1. 5. 9. Packages 1. 5. 10. Traits 1. 5. 11. Multithreading and Asynchronous Programming 1. 6. Review 1. 7. Quiz References Chapter 2: Exploring Axum Fundamentals 2. 1. HTTP Fundamentals 2. 2. Creating an Axum Project 2. 3. Routers and Handlers 2. 3. 1. Defining Routers 2. 3. 2. Defining Handlers 2. 3. 3. Sending Responses from Handlers 2. 3. 4. Status Codes and Headers 2. 4. State Management 2. 4. 1. State 2. 4. 2. Extension 2. 5. Handler Debugging 2. 6. Example: Creating a Proxy Server 2. 7. Review
Page 13
Chapter 3: Database Integration with SeaORM 3. 1. What Is ORM? 3. 1. 1. What Is SeaORM? 3. 2. Creating Schemas and Models 3. 2. 1. Defining Database Schema 3. 2. 2. Installing Dependencies 3. 2. 3. Migration 3. 3. SeaQuery 3. 3. 1. Query Builder 3. 3. 2. Identifiers and Iden 3. 3. 3. Database Connection 3. 3. 4. SELECT 3. 3. 5. INSERT 3. 3. 6. UPDATE 3. 3. 7. DELETE 3. 3. 8. Error Handling 3. 4. Connecting Users Table to HTTP Requests 3. 5. Database Connection 3. 5. 1. Connection Pool 3. 5. 2. Connection Options 3. 6. Modularization 3. 6. 1. Separating the DB Module 3. 6. 2. API Module Separation 3. 7. Completing Remaining Endpoints
Page 14
3. 7. 1. Category 3. 7. 2. Product 3. 7. 3. Routing 3. 8. Trying DBeaver 3. 9. Review Reference Chapter 4: Tower Middleware 4. 1. What Is Middleware? 4. 2. Adding Middleware Layers 4. 2. 1. Timeout Layer 4. 2. 2. Logging Layer 4. 2. 3. Compression Layer 4. 3. Example: Creating a JWT Authentication Layer 4. 4. Review Chapter 5: WebSocket 5. 1. Exploring WebSocket 5. 2. Using WebSocket 5. 3. Concurrent WebSocket Connections 5. 4. Authentication Headers 5. 5. Review Chapter 6: Project: Building a Chat Service 6. 1. Project Overview 6. 1. 1. What Is SSE? 6. 1. 2. Code Repository
Page 15
6. 2. Hands-on 6. 2. 1. Project Setup 6. 2. 2. Creating SSE Endpoints 6. 2. 3. Configuration Management and Database Connection 6. 2. 4. Creating REST API Endpoints 6. 2. 5. Building the Frontend 6. 2. 6. Automated Testing 6. 2. 7. Production Readiness and Deployment 6. 3. Review 6. 4. Closing Index
Page 16
About the Author Indo Yoon is a software engineer at SAP Labs Korea specializing in Python, Rust, and Go. A Seoul National University alumnus, he extends his impact beyond code as a frequent speaker and technical author. With a strong focus on web services, Indo is dedicated to advancing the developer community through his lectures and written works.  
Page 17
About the Technical Reviewer Joshua Mo is a software engineer and technical writer specializing in Rust, AI infrastructure, and web development. He is currently the project lead for Rig, an open-source Rust framework for building agentic and AI- driven systems, where he focuses on system design, reliability, and developer ergonomics. Previously, Joshua worked at Shuttle, where he wrote many articles on using Axum, helped drive Rust adoption across companies, and supported developers learning async Rust and modern Rust web frameworks. He is known for translating real-world engineering experience into practical, production-focused guidance.  
Page 18
(1) © The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2026 I. Yoon, Beginning Axum https://doi.org/10.1007/979-8-8688-2631-3_1 1. Rust and Server Development Indo Yoon1   Seoul, Korea (Republic of)   Backend servers are the core of web applications. They connect frontends to databases, process and deliver data, and handle essential service operations like security, logging, and monitoring. Today, companies use many different programming languages and frameworks for backend development. What makes Rust stand out among them? Which companies are actually using Rust for their production backends? Learning Points Why Rust excels at backend development Real-world case studies of Rust backends in production Essential components for Rust server development 1.1 Why Rust? To understand why Rust excels at server development, we need to first examine what makes Rust itself so powerful. 1.1.1 Advantages of Rust Rust is a modern programming language that makes it easy to build fast, reliable programs. It delivers performance nearly identical to C/C++ (about 99%), but catches memory leaks and thread race conditions at compile time —problems that have plagued C/C++ developers for decades. This
Page 19
combination of high performance and high safety has made Rust the most desired language among developers for eight consecutive years in Stack Overflow’s global developer surveys [1]. Beyond performance and safety, Rust’s popularity stems from its excellent developer experience. As a modern language, it features elegant syntax and clear style guidelines that help you write correct code. Features like pattern matching and closures let you express complex logic concisely and efficiently. The compiler acts like a pair programmer—it not only identifies problems but also suggests solutions, helping you write the code you want faster. Rust also provides a convenient toolchain. A single toolchain called cargo handles everything from building and deploying to installing and updating dependencies. Additionally, rust-analyzer analyzes your source code in real time and provides immediate feedback as you write. It provides code completion, references to the code, type hints, and inline error messages in IDEs such as Visual Studio Code. Detailed instructions will be covered later. 1.1.2 Advantages of Developing Backends with Rust The advantage of developing backend servers with Rust is that you can easily build servers with both high performance and safety. For example, developing servers with JavaScript or Python often means hitting language- imposed performance limitations or spending significant time resolving thread race conditions and other concurrency issues. Even Java, widely used in Korea, can experience delays in server response times due to garbage collection pauses. In short, Rust is the ideal language for developing large-scale servers that require heavy CPU computation. 1.2 Rust Server Development Case Studies Leading tech companies like Microsoft, Cloudflare, Facebook, and Amazon are already actively adopting Rust for their backends. In Korea, companies like Kakao and Korbit have also adopted Rust as their backend language.
Page 20
Let’s examine some famous cases where companies used Rust to solve problems like concurrency limitations and performance degradation from garbage collection. 1.2.1 Figma Figma is a browser-based UI prototyping tool. Reflecting design shapes and functionality to users in real time is crucial. However, as the service grew, increased user load caused the existing TypeScript server’s CPU and memory usage to spike, leading to longer response times. To solve this, they decided to rewrite the server in Rust. The results were dramatic: compared to the TypeScript server, memory usage improved by up to 3.8x and response times improved by up to 16.4x [2]. 1.2.2 Discord Discord is a messenger service for text and video chat. As the service grew, they discovered periodic performance drops in their existing Go-based backend server. In the graph in Figure 1-1, the sections with periodic spikes represent the original server written in Go. You can see CPU usage spiking periodically, temporarily overloading the server and causing response times to increase cyclically. This was caused by Go’s garbage collector—while it periodically removes unused objects from memory, all other operations must pause. After rewriting the server in Rust, CPU usage stabilized and response times became much shorter.
The above is a preview of the first 20 pages. Register to read the complete e-book.

Support Author

0.00
Total Amount (¥)
0
Donation Count
Please enter an amount Minimum ¥1

You will be redirected to Alipay to complete payment, then return here.

Recommended for You

Loading recommended books...
Failed to load, please try again later
Back to List