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

Add getters for &ServiceRequest #2786

Merged
merged 4 commits into from Jun 22, 2022
Merged

Conversation

junbl
Copy link
Contributor

@junbl junbl commented Jun 17, 2022

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.*
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

*no tests necessary; none for parts_mut/into_parts or other getters

Overview

Adds getters for cases when you only have a &ServiceRequest and need access to the inner parts.

  • parts: returns immutable refs to the inner request and payload. Non-owning counterpart to into_parts and parts_mut.
  • request: just gives access to the HttpRequest since there's not a lot you can do with a &Payload currently.

This allows access to parts of the HttpRequest not already covered by the existing getters. Additionally, this allows FromRequesting types that don't require access to the Payload, like Identity. (ServiceRequest::extract, while covering a similar use case, requires a &mut ServiceRequest and thus isn't usable in this context.)

No breaking changes.

Use case mentioned in #2175, but it doesn't seem like the associated issue was ever opened.

@robjtede robjtede added B-semver-minor A-web project: actix-web labels Jun 21, 2022
@robjtede robjtede added this to the actix-web v4.2 milestone Jun 21, 2022
Copy link
Member

@robjtede robjtede left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@robjtede robjtede merged commit 5d0e813 into actix:master Jun 22, 2022
@junbl junbl deleted the servicerequest_ref_getter branch June 22, 2022 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants