-
hi, I want to use the Path extractor in the middleware to do authorization authentication through the url parameter,The following writing method does not work properly, Looking at the documentation, no examples of Path parameters in middleware were found pub async fn auth<B>(
mut req: Request<B>,
next: Next<B>,
) -> Result<Response, StatusCode> {
match req.extensions().get::<Path<(String, String, String)>>() {
Some(Path((username, password, mac))) => {
//some code auth
//req.extensions_mut().insert(robot_data);
Ok(next.run(req).await)
}
None => {
Err(StatusCode::UNAUTHORIZED)
},
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
yuhaya
Dec 1, 2022
Replies: 1 comment
-
found a way pub async fn auth<B>(
Path((username, password, mac)): Path<(String, String, String)>,
Host(addr): Host,
mut req: Request<B>,
next: Next<B>,
) -> Result<Response, StatusCode> {
//...
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yuhaya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
found a way