Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Rust Web Programming
  • Table Of Contents Toc
Rust Web Programming

Rust Web Programming - Third Edition

By : Maxwell Flitton
4 (1)
close
close
Rust Web Programming

Rust Web Programming

4 (1)
By: Maxwell Flitton

Overview of this book

Rust is no longer just for systems programming. This book will show you why this safe and performant language is a crucial up-and-coming option for developing web applications, and get you on your way to building fully functional Rust web apps. You don’t need any experience with Rust to get started, and this new edition also comes with a shallower learning curve. You’ll get hands-on with emerging Rust web frameworks including Actix, Axum, Rocket, and Hyper. You’ll look at injecting Rust into the frontend with WebAssembly and HTTPS configuration with NGINX. Later, you’ll move on to more advanced async topics, exploring TCP and framing, and implementing async systems. As you work through the book, you’ll build a to-do application with authentication using a microservice architecture that compiles into one Rust binary, including the embedding of a frontend JavaScript application in the same binary. The application will have end-to-end atomic testing and a deployment pipeline. By the end of this book, you’ll fully understand the significance of Rust for web development. You’ll also have the confidence to build robust, functional, and scalable Rust web applications from scratch.
Table of Contents (24 chapters)
close
close
22
Other Books You May Enjoy
23
Index

Decoding our token

We can encode our token with the code below:

// glue/src/token.rs
pub fn decode(token: &str) -> Result<Self, NanoServiceError> {
    let key_str = Self::get_key()?;
    let key = DecodingKey::from_secret(key_str.as_ref());
    let mut validation = Validation::new(Algorithm::HS256);
    validation.required_spec_claims.remove("exp");
    match decode::<Self>(token, &key, &validation) {
        Ok(token_data) => return Ok(token_data.claims),
        Err(error) => return Err(
            NanoServiceError::new(
                error.to_string(),
                NanoServiceErrorStatus::Unauthorized
            )
        )
    };
}

Here we can see that we get the key from the environment variable again. We then create a decoding key, with the HS256 algorithm. From this, we can deduce that the default encoding in the previous section was the HS256 algorithm. We then remove the "exp" from the claims. This means that we are...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Rust Web Programming
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon