Extracting data from HTTP request headers
In this section, we will not implement full authentication, as this will be addressed in Chapter 10. Here, we are just going to extract a string from the header.
Before we write any more code, we must add the following dependency to our glue module as we will be using futures in our implementation of the extractor traits:
# File: glue/Cargo.toml
. . .
[dependencies]
. . .
futures = "0.3.30"
When it comes to headers, we can store credentials or metadata around the HTTP request. Before we get into inspecting the headers of our HTTP requests, we must define our token in our glue workspace because we are going to use the token for authentication in the future. Every service should have the right to enforce authentication without having to rewrite the token implementation.
Defining our header token modules
We want our glue module to support header extraction for all our different web frameworks. Therefore, our token...