Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-destructive access to a request/payload of a ServiceRequest #2175

Closed
andy128k opened this issue Apr 19, 2021 · 2 comments · Fixed by #2177
Closed

Allow non-destructive access to a request/payload of a ServiceRequest #2175

andy128k opened this issue Apr 19, 2021 · 2 comments · Fixed by #2177
Labels
A-web project: actix-web C-feature Category: new functionality

Comments

@andy128k
Copy link
Contributor

Expected Behavior

Expose references (mutable references) to a request and a payload of a ServiceRequest.

Current Behavior

ServiceRequest allows to get a request and a payload by invoking into_parts method. But this method consumes a ServiceRequest.

Possible Solution

  1. Add getters (mutable getters).
  2. Make fields public.

Context

A middleware may have a need to access a request (or a payload) by a borrowed reference to A ServiceRequest.
Related issues: #2168 #1821

@robjtede robjtede added C-feature Category: new functionality A-web project: actix-web labels Apr 19, 2021
@robjtede robjtede changed the title [Feature request] Allow non-destructive access to a request/payload of a ServiceRequest Allow non-destructive access to a request/payload of a ServiceRequest Apr 19, 2021
@robjtede robjtede added this to the actix-web post-v4 milestone Apr 22, 2021
@ilyvion
Copy link

ilyvion commented Sep 12, 2021

I really don't understand why it was decided to only add a parts_mut and not also a parts. I'm in a situation where I have a &ServiceRequest and I can't find any (non-UB) way of getting a hold of the inner &HttpRequest.

@aliemjay
Copy link
Member

I really don't understand why it was decided to only add a parts_mut and not also a parts. I'm in a situation where I have a &ServiceRequest and I can't find any (non-UB) way of getting a hold of the inner &HttpRequest.

This quite reasonable. Please consider opening another issue that covers ServiceResponse as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web C-feature Category: new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants