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

Implement FromRequest for http::request::Parts #489

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

davidpdrsn
Copy link
Member

Its a convenient way to extract everything from the request except the
body. Also makes sense for axum to provide this since other crates
can't.

@davidpdrsn davidpdrsn added the C-enhancement Category: A PR with an enhancement label Nov 9, 2021
Its a convenient way to extract everything from a request except the
body. Also makes sense for axum to provide this since other crates
can't.
Comment on lines +340 to +347
let mut temp_request = Request::new(());
*temp_request.method_mut() = method;
*temp_request.uri_mut() = uri;
*temp_request.version_mut() = version;
*temp_request.headers_mut() = headers;
*temp_request.extensions_mut() = extensions;

let (parts, _) = temp_request.into_parts();
Copy link
Member

Choose a reason for hiding this comment

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

It's unfortunate that there is no way to exhaustively create request::Parts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah 😞

@davidpdrsn davidpdrsn enabled auto-merge (squash) November 9, 2021 20:33
@davidpdrsn davidpdrsn merged commit fdd8895 into main Nov 9, 2021
@davidpdrsn davidpdrsn deleted the extract-request-parts branch November 9, 2021 20:37
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- Implement `FromRequest` for [`http::request::Parts`] so it can be used an
  extractor ([#489])
- Implement `IntoResponse` for `http::response::Parts` ([#490])

[#489]: #489
[#490]: #490
[`http::request::Parts`]: https://docs.rs/http/latest/http/request/struct.Parts.html
@davidpdrsn davidpdrsn mentioned this pull request Nov 13, 2021
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- Implement `FromRequest` for [`http::request::Parts`] so it can be used an
  extractor ([#489])
- Implement `IntoResponse` for `http::response::Parts` ([#490])

[#489]: #489
[#490]: #490
[`http::request::Parts`]: https://docs.rs/http/latest/http/request/struct.Parts.html
EdorianDark pushed a commit to EdorianDark/axum that referenced this pull request Nov 24, 2021
Its a convenient way to extract everything from a request except the
body. Also makes sense for axum to provide this since other crates
can't.
EdorianDark pushed a commit to EdorianDark/axum that referenced this pull request Nov 24, 2021
- Implement `FromRequest` for [`http::request::Parts`] so it can be used an
  extractor ([tokio-rs#489])
- Implement `IntoResponse` for `http::response::Parts` ([tokio-rs#490])

[tokio-rs#489]: tokio-rs#489
[tokio-rs#490]: tokio-rs#490
[`http::request::Parts`]: https://docs.rs/http/latest/http/request/struct.Parts.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A PR with an enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants