E-Book, Englisch, 666 Seiten
Flitton Rust Web Programming
2. Auflage 2023
ISBN: 978-1-80323-665-0
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
A hands-on guide to developing, packaging, and deploying fully functional Rust web applications
E-Book, Englisch, 666 Seiten
ISBN: 978-1-80323-665-0
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection
No detailed description available for "Rust Web Programming".
Autoren/Hrsg.
Fachgebiete
Weitere Infos & Material
Table of Contents - A Quick Introduction to Rust
- Designing Your Web Application in Rust
- Handling HTTP Requests
- Processing HTTP Requests
- Displaying Content in the Browser
- Data persistence with PostgreSQL
- Managing User Sessions
- Building RESTful Services
- Testing Our Application Endpoints and Components
- Deploying Our Application on AWS
- Configuring HTTPS with NGINX on AWS
- Recreating Our Application in Rocket
- Best Practices for a Clean Web App Repository
- Exploring the Tokio Framework
- Accepting TCP Traffic with Tokio
- Building Protocols on Top of TCP
- Implementing Actors and Async with the Hyper Framework
- Queuing Tasks with Redis
Preface
Do you want to push your web applications to the limit for speed and low energy consumption but still have memory safety? Rust enables you to have memory safety without the garbage collection and a similar energy consumption as the C programming language. This means you can create high-performance and secure applications with relative ease. This book will take you through each stage of web development resulting in you deploying advanced web applications built in Rust and packaged in distroless Docker, resulting in server images around the size of 50 MB on AWS using automated build and deployment pipes that we created. You’ll start with an introduction to programming in Rust so you can avoid the common pitfalls when migrating from a traditional dynamic programming language. The book will show you how to structure Rust code for a project that spans multiple pages and modules. Next, you’ll explore the Actix Web framework and get a basic web server up and running. As you advance, you’ll learn how to process JSON requests and display the data from the server via HTML, CSS, and JavaScript and even build a basic React application for our data. You’ll also learn how to persist data and create RESTful services in Rust, where we log in and authenticate users and cache data in the frontend. Later, you’ll build an automated build and deployment process for the app on AWS over two EC2 instances, where we load balance the HTTPS traffic from a registered domain to our application on those EC2 instances, which we will build using Terraform. You will also lock down the traffic directly to the EC2 instances by configuring security groups in Terraform. You’ll then cover multi-layered builds to produce distroless Rust images. Finally, you’ll cover advanced web concepts exploring async Rust, Tokio, Hyper, and TCP framing. With these tools, you will implement the actor model to enable you to implement advanced complex async real-time event processing systems, practicing by building a basic stock purchasing system. You’ll finish the book by building your own queuing mechanism on Redis, where your own Rust home-built server and worker nodes consume the tasks on the queue and process these tasks. Who this book is for
This book on web programming with Rust is for web developers who have programmed in traditional languages, such as Python, Ruby, JavaScript, and Java, and are looking to develop high-performance web applications with Rust. Although no prior experience with Rust is necessary, a solid understanding of web development principles and basic knowledge of HTML, CSS, and JavaScript is required if you want to get the most out of this book. 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. To get the most out of this book
You will need to know some basic concepts around HTML and CSS. You will also need to have some basic understanding of JavaScript. However, the HTML, CSS, and JavaScript is only needed for displaying data in the browser. If you are just reading the book to build backend API servers in Rust, then knowledge of HTML, CSS, and JavaScript is not needed. Some basic understanding of programming concepts such as functions and loops will also be needed as these will not be covered in the book. Software/hardware covered in the book Operating system requirements Rust Windows, macOS, or Linux (any) Node (for JavaScript) Windows, macOS, or Linux (any) Python 3 Windows, macOS, or Linux (any) Docker Windows, macOS, or Linux (any) docker-compose Windows, macOS, or Linux (any) Postman Windows, macOS, or Linux (any) Terraform Windows, macOS, or Linux (any) To take full advantage of the deployment on AWS chapters, you will need an AWS account, which might cost if you are not eligible for the Free Tier. However, the builds are automated with Terraform, so spinning up builds and tearing them down will be quick and easy, so you will not need to keep the infrastructure running while working through the book, keeping the costs to a minimum. If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code. By the of this book, you will have a solid foundation of building and deploying Rust servers. However, it must be noted that Rust is a powerful language. As this book focuses on web programming and deployment, there is scope for improvement in Rust programming after the book. Further reading on Rust is advised after the book to enable you to solve more complex problems. Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Rust-Web-Programming-2nd-Edition....