Rust web programming a hands-on guide to developing, packaging, and deploying fully functional rust web applications
Use the Rust programming language to build fully functional web applications with async Rust to amplify security and boost the performance of your programs Key Features Work with cutting-edge web techniques such as distroless Rust servers, Terraform, and AWS deployment Get acquainted with async conc...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Birmingham, England ; Mumbai :
Packt Publishing
[2023]
|
Edición: | Second edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009717638506719 |
Tabla de Contenidos:
- Cover
- Title Page
- Copyright and Credits
- Contributors
- About the reviewers
- Table of Contents
- Preface
- Part 1: Getting Started with Rust Web Development
- Chapter 1: A Quick Introduction to Rust
- Technical requirements
- Why is Rust revolutionary?
- Reviewing data types and variables in Rust
- Using strings in Rust
- Using integers and floats
- Storing data in vectors and arrays
- Mapping data with HashMaps
- Handling results and errors
- Controlling variable ownership
- Copying variables
- Moving variables
- Immutable borrowing of variables
- Mutable borrowing of variables
- Scopes
- Running through lifetimes
- Building structs
- Verifying with traits
- Metaprogramming with macros
- Summary
- Questions
- Answers
- Further reading
- Chapter 2: Designing Your Web Application in Rust
- Technical requirements
- Managing a software project with Cargo
- Building with Cargo
- Shipping crates with Cargo
- Documenting with Cargo
- Interacting with Cargo
- Structuring code
- Building to-do structs
- Managing structs with factories
- Defining functionality with traits
- Interacting with the environment
- Reading and writing JSON files
- Revisiting traits
- Processing traits and structs
- Summary
- Questions
- Answers
- Part 2: Processing Data and Managing Displays
- Chapter 3: Handling HTTP Requests
- Technical requirements
- Introducing the Actix Web framework
- Launching a basic Actix Web server
- Understanding closures
- Understanding asynchronous programming
- Understanding async and await
- Exploring async and await with web programming
- Managing views using the Actix Web framework
- Summary
- Questions
- Answers
- Further reading
- Chapter 4: Processing HTTP Requests
- Technical requirements
- Getting to know the initial setup for fusing code.
- Passing parameters into views
- Using macros for JSON serialization
- Building our own serialization struct
- Implementing the Serialize trait
- Integrating serialization structs into our application code
- Packaging our custom serialized struct to be returned to users
- Extracting data from views
- Extracting JSON from the body of a request
- Extracting data from the header in requests
- Simplifying header extraction with traits
- Summary
- Questions
- Answers
- Chapter 5: Displaying Content in the Browser
- Technical requirements
- Serving HTML, CSS, and JavaScript using Rust
- Serving basic HTML
- Reading basic HTML from files
- Serving basic HTML loaded from files
- Adding JavaScript to an HTML file
- Communicating with our server using JavaScript
- Injecting JavaScript into HTML
- Adding the delete endpoint
- Adding a JavaScript loading function
- Adding JavaScript tags in the HTML
- Building a rendering JavaScript function
- Building an API call JavaScript function
- Building JavaScript functions for buttons
- Injecting CSS into HTML
- Adding CSS tags to HTML
- Creating a base CSS
- Creating CSS for the home page
- Serving CSS and JavaScript from Rust
- Inheriting components
- Creating a React app
- Making API calls in React
- Creating custom components in React
- Creating our ToDoItem component
- Creating custom components in React
- Constructing and managing custom components in our App component
- Lifting CSS into React
- Converting our React application into a desktop application
- Summary
- Questions
- Answers
- Further reading
- Part 3: Data Persistence
- Chapter 6: Data Persistence with PostgreSQL
- Technical requirements
- Building our PostgreSQL database
- Why we should use a proper database
- Why use Docker?
- How to use Docker to run a database
- Running a database in Docker.
- Exploring routing and ports in Docker
- Running Docker in the background with Bash scripts
- Connecting to PostgreSQL with Diesel
- Connecting our app to PostgreSQL
- Creating our data models
- Getting data from the database
- Inserting into the database
- Editing the database
- Deleting data
- Configuring our application
- Building a database connection pool
- Summary
- Questions
- Answers
- Chapter 7: Managing User Sessions
- Technical requirements
- Creating our user model
- Creating a User data module
- Creating a NewUser data model
- Altering the to-do item data model
- Updating the schema file
- Creating and running migration scripts on the database
- Authenticating our users
- Managing user sessions
- Cleaning up authentication requirements
- Configuring expiration of auth tokens
- Adding authentication into our frontend
- Summary
- Questions
- Answers
- Further reading
- Appendix
- Chapter 8: Building RESTful Services
- Technical requirements
- What are RESTful services?
- Mapping our layered system
- Building a uniform interface
- Implementing statelessness
- Logging our server traffic
- Caching
- Code on demand
- Summary
- Questions
- Answers
- Part 4: Testing and Deployment
- Chapter 9: Testing Our Application Endpoints and Components
- Technical requirements
- Building our unit tests
- Building JWT unit tests
- Building a configuration for tests
- Defining the requirements for JWT tests
- Building basic function tests for JWT
- Building tests for web requests
- Writing tests in Postman
- Writing ordered requests for tests
- Creating a test for an HTTP request
- Automating Postman tests with Newman
- Building an entire automated testing pipeline
- Summary
- Questions
- Answers
- Further reading
- Chapter 10: Deploying Our Application on AWS
- Technical requirements.
- Setting up our build environment
- Setting up an AWS SSH key for an AWS EC2 instance
- Setting up our AWS client
- Setting up our Terraform build
- Writing our Python application build script
- Writing our Bash deployment script
- Managing our software with Docker
- Writing Docker image files
- Building Docker images
- Building an EC2 build server using Terraform
- Orchestrating builds with Bash
- Writing a Docker image file for the React frontend
- Deploying images onto Docker Hub
- Deploying our application on AWS
- Running our application locally
- Running our application on AWS
- Writing our application build script
- Summary
- Further reading
- Chapter 11: Configuring HTTPS with NGINX on AWS
- Technical requirements
- What is HTTPS?
- Binary protocol
- Compressed headers
- Persistent connections
- Multiplex streaming
- Implementing HTTPS locally with docker-compose
- Attaching a URL to our deployed application on AWS
- Attaching an elastic IP to our server
- Registering a domain name
- Enforcing HTTPS on our application on AWS
- Getting certificates for our URL
- Creating multiple EC2 instances
- Creating a load balancer for our traffic
- Creating security groups to lock down and secure traffic
- Updating our Python deployment script for multiple EC2 instances
- Attaching our URL to the load balancer
- Summary
- Further reading
- Questions
- Answers
- Part 5: Making Our Projects Flexible
- Chapter 12: Recreating Our Application in Rocket
- Technical requirements
- What is Rocket?
- Setting up our server
- Plugging in our existing modules
- Implementing Rocket traits
- Plugging in our existing views
- Accepting and returning JSON
- Returning raw HTML
- Returning status with JSON
- Returning multiple statuses
- Registering our views with Rocket
- Plugging in our existing tests
- Summary.
- Further reading
- Questions
- Answers
- Chapter 13: Best Practices for a Clean Web App Repository
- Technical requirements
- The general layout of a clean repository
- Getting our configuration from environment variables
- Setting up a local development database
- Managing variables in Postman tests
- Building distroless tiny server Docker images
- Building a clean test pipeline
- Building continuous integration with GitHub Actions
- Summary
- Further reading
- Questions
- Answers
- Part 6: Exploring Protocol Programming and Async Concepts with Low-Level Network Applications
- Chapter 14: Exploring the Tokio Framework
- Technical requirements
- Exploring the Tokio framework for async programming
- Working with workers
- Exploring the actor model for async programming
- Working with channels
- Working with actors in Tokio
- Summary
- Further reading
- Questions
- Answers
- Chapter 15: Accepting TCP Traffic with Tokio
- Technical requirements
- Exploring TCP
- Accepting TCP
- Processing bytes
- Passing TCP to an actor
- Keeping track of orders with actors
- Chaining communication between actors
- Responding with TCP
- Sending different commands via the client
- Summary
- Further reading
- Questions
- Answers
- Chapter 16: Building Protocols on Top of TCP
- Technical requirements
- Setting up our TCP client and server
- Setting up our TCP server
- Setting up our TCP client
- Processing bytes using structs
- Creating a message sender client
- Processing messages in the server
- Utilizing framing
- Rewriting our client so that it supports framing
- Rewriting our server so that it supports framing
- Building an HTTP frame on top of TCP
- Summary
- Further reading
- Questions
- Answers
- Chapter 17: Implementing Actors and Async with the Hyper Framework
- Technical requirements.
- Breaking down our project.