Skip to content

How to get request parts uri from inside a middleware? #3022

Answered by yanns
squeaktoy asked this question in Q&A
Discussion options

You must be logged in to vote

Could read the uri before the async move block?
like:

    fn call(&mut self, request: Request) -> Self::Future {
        let uri = request.uri().clone();
        let future = self.inner.call(request);

        Box::pin(async move {
            println!("Request to {}", uri);
            let response: Response = future.await?;
            Ok(response)
        })
    }

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@squeaktoy
Comment options

@yanns
Comment options

yanns Nov 10, 2024
Collaborator

@squeaktoy
Comment options

@yanns
Comment options

yanns Nov 11, 2024
Collaborator

Answer selected by squeaktoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants