Skip to content

Add raw pre_send method #285

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

Merged
merged 9 commits into from
Dec 11, 2017
Merged

Add raw pre_send method #285

merged 9 commits into from
Dec 11, 2017

Conversation

KodrAus
Copy link
Member

@KodrAus KodrAus commented Dec 1, 2017

For #281

I've marked this as a breaking change because it depends on some breaking work done already.

Adds a pre_send_raw method to the Sync and Async clients that can be used to inspect and tweak a raw request before it goes out. This makes it convenient to do things like sign ready-to-send requests, but shouldn't be used for cases like adding simple headers or query params that should be done through params.

I'll add an example case and this should be ready to go.

Changes

elastic_requests

  • Rename HttpRequest to Endpoint
  • Rename Url to UrlPath
  • Remove HttpMethod and re-export http::Method

elastic_responses

  • Export http::StatusCode
  • Replace case taking a u16 status with StatusCode

elastic

  • Add some new raw http request types that include headers and can be inspected
  • Allow tweaking a raw request before sending

TODO

  • Replace u16 in elastic_responses with http::StatusCode (this is a bit of churn but shouldn't impact people much)
  • Make the body types readable with streams again (means buffering files which should be called out in the docs)
  • Make sure the module hierarchy makes sense

Essentially I want to get a foot in the door using the sharable types from http.

@KodrAus
Copy link
Member Author

KodrAus commented Dec 1, 2017

Looks like we'll need a dedicated request type for this to work, because you can't read reqwest request bodies so the usecase of signing requests won't work.

I think it's a good chance to pull in the http crate and use its types.

@KodrAus
Copy link
Member Author

KodrAus commented Dec 2, 2017

Ok I'm going halfway with this, renaming types in elastic_requests the their intent is clearer (changing HttpRequest to Endpoint) and adding an inspectible http request type to elastic. It needs a lot of cleanup but the basics are there.

I think I need to shift the requests and sender modules around a bit. It's got a lot of stuff sitting in the respective roots.

@KodrAus KodrAus merged commit c8b4ba3 into vNext Dec 11, 2017
@KodrAus KodrAus deleted the feat/pre-send-methods branch December 11, 2017 22:50
@KodrAus KodrAus mentioned this pull request Jan 10, 2018
KodrAus added a commit that referenced this pull request Apr 29, 2018
* add raw pre_send method

* introduce `http` crate for shared HTTP types
KodrAus added a commit that referenced this pull request May 7, 2018
* add raw pre_send method

* introduce `http` crate for shared HTTP types
KodrAus added a commit that referenced this pull request Jan 25, 2019
* add raw pre_send method

* introduce `http` crate for shared HTTP types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant