-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AsyncHttpClient and SyncHttpClient traits
Previously, this crate defined its own `HttpRequest`/`HttpResponse` types and used `Fn` traits to define the HTTP client interfaces. This change replaces the `HttpRequest` and `HttpResponse` structs with type aliases to use `http::Request` and `http::Response`, respectively (#236). It also replaces the `Fn`-based interface with new `AsyncHttpClient` and `SyncHttpClient` traits. The corresponding `http_client` and `async_http_client` implementations (for `reqwest`, `curl`, and `ureq`) are replaced with trait implementations on stateful clients, where available. For example, `AsyncHttpClient` is now implemented for `reqwest::Client`, which allows connection reuse between requests. For convenience, these traits are also implemented for `Fn` types to support custom clients without requiring an explicit trait implementation. BREAKING CHANGES: - Each `request()` method now accepts a reference to a type implementing `SyncHttpClient`, rather than an owned function type. - Each `request_async()` method now accepts a reference to a type implementing `AsyncHttpClient`, rather than an owned function type. They now return `Pin<Box<dyn Future>>`` instead of being declared as `async fn`s. - `HttpRequest` is now a type alias to `http::Request`. - `HttpResponse` is now a type alias to `http::Response`. - `curl::http_client` has been replaced with `curl::CurlHttpClient`. - `reqwest::async_http_client` has been replaced with the `AsyncHttpClient` trait being implemented for `reqwest::Client`. - `reqwest::sync_http_client` has been replaced with the `SyncHttpClient` trait being implemented for `reqwest::blocking::Client`. - `ureq::http_client` has been replaced with the `SyncHttpClient` trait being implemented for `ureq::Agent`. Resolves #163. Resolves #236. Resolves #253.
- Loading branch information
Showing
21 changed files
with
1,154 additions
and
933 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.