Book Image

Rust Web Programming - Second Edition

By : Maxwell Flitton
Book Image

Rust Web Programming - Second Edition

By: Maxwell Flitton

Overview of this book

Are safety and high performance a big concern for you while developing web applications? With this practical Rust book, you’ll discover how you can implement Rust on the web to achieve the desired performance and security as you learn techniques and tooling to build fully operational web apps. In this second edition, you’ll get hands-on with implementing emerging Rust web frameworks, including Actix, Rocket, and Hyper. It also features HTTPS configuration on AWS when deploying a web application and introduces you to Terraform for automating the building of web infrastructure on AWS. What’s more, this edition also covers advanced async topics. Built on the Tokio async runtime, this explores TCP and framing, implementing async systems with the actor framework, and queuing tasks on Redis to be consumed by a number of worker nodes. Finally, you’ll go over best practices for packaging Rust servers in distroless Rust Docker images with database drivers, so your servers are a total size of 50Mb each. By the end of this book, you’ll have confidence in your skills to build robust, functional, and scalable web applications from scratch.
Table of Contents (27 chapters)
Free Chapter
1
Part 1:Getting Started with Rust Web Development
4
Part 2:Processing Data and Managing Displays
8
Part 3:Data Persistence
12
Part 4:Testing and Deployment
16
Part 5:Making Our Projects Flexible
19
Part 6:Exploring Protocol Programming and Async Concepts with Low-Level Network Applications

What this book covers

Chapter 1, A Quick Introduction to Rust, provides the basics of the Rust programming language.

Chapter 2, Designing Your Web Application in Rust, covers building and managing applications in Rust.

Chapter 3, Handling HTTP Requests, covers building a basic Rust server that handles HTTP requests using the Actix Web framework.

Chapter 4, Processing HTTP Requests, covers extracting and handling data from an incoming HTTP request.

Chapter 5, Displaying Content in the Browser, covers displaying data from the server and sending requests to the server from the browser with HTML, CSS, and JavaScript with React.

Chapter 6, Data Persistence with PostgreSQL, covers managing and structuring data in PostgreSQL and interacting with the database with our Rust web server.

Chapter 7, Managing User Sessions, covers authentication and managing of user sessions when making requests to the web server.

Chapter 8, Building RESTful Services, covers implementing RESTful concepts for Rust web servers.

Chapter 9, Testing Our Application Endpoints and Components, covers end-to-end testing pipelines and unit testing on Rust web servers using Postman.

Chapter 10, Deploying Our Application on AWS, covers building automated build and deployment pipelines to deploy on AWS using Docker and automating the infrastructure building with Terraform.

Chapter 11, Configuring HTTPS with NGINX on AWS, covers configuring HTTPS and routing to servers via load balancing on AWS with NGINX and routing traffic to different applications depending on endpoints in the URL.

Chapter 12, Recreating Our Application in Rocket, covers slotting our existing application into a Rocket web framework.

Chapter 13, Best Practices for a Clean Web App Repository, covers cleaning up a web application repository with multi-stage Docker builds for smaller images and init Docker containers to automate database migrations on deployment.

Chapter 14, Exploring the Tokio Framework, covers implementing basic async code using the Tokio framework to facilitate an async runtime.

Chapter 15, Accepting TCP Traffic with Tokio, covers sending, receiving, and processing TCP traffic.

Chapter 16, Building Protocols on Top of TCP, covers processing TCP byte streams into advanced data structures using structs and framing.

Chapter 17, Implementing Actors and Async with the Hyper Framework, covers building an async system using the actor framework that accepts HTTP requests via the Hyper framework.

Chapter 18, Queuing Tasks with Redis, covers accepting HTTP requests and packaging them as tasks to put on a Redis queue for a pool of workers to process.