Implementing Rocket traits
Most of the logic that we have defined in our modules that we copied over can be directly referenced in our code. However, we do have to utilize the database connection and the JWT struct that had Actix Web trait implementations. If we are to copy over our views, we are going to have to implement Rocket traits for the database connection and JWT authentication because we pass them into our view functions in the Actix Web application.
Before we implement the Rocket traits, we must copy over the JWT file with the following command:
cp web_app/src/jwt.rs rocket_app/src/jwt.rs
We then must declare the following dependency in the Cargo.toml
file with the following code:
jsonwebtoken = "8.1.0"
We can now move on to the src/jwt.rs
file for our Rocket trait implementation. First, we must import the following traits and structs at the top of the file with the following code:
use rocket::http::Status; use rocket::request::{self, Outcome...