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

Replace middleware API with interceptors API #206

Merged
merged 10 commits into from
Oct 11, 2020
Merged

Replace middleware API with interceptors API #206

merged 10 commits into from
Oct 11, 2020

Conversation

sagebind
Copy link
Owner

@sagebind sagebind commented Jul 16, 2020

Implement an interceptors API and remove the old middleware API.

The new interceptors API is gated behind the unstable-interceptors feature flag. We sort of need to rush this out the door in order to implement #215 properly, but we're not ready to finalize the design yet. There are still some open problems to fix with this:

  • from_fn doesn't work as desired. The trait bounds are too ambiguous for the compiler to infer for closures, and since the return type is generic over a lifetime, there's no way to give the return type the correct name using current Rust syntax.
  • InterceptorObj wraps the returned future in an extra box.
  • If an interceptor returns a custom error, it is stringified and wrapped in Error::Curl. We should introduce a new error variant that boxes the error and also records the type of the interceptor that created the error for visibility.
  • Automatic redirect following currently bypasses interceptors for subsequent requests. This will be fixed when redirect handling is rewritten as an interceptor itself. See Cookies aren't sent when following redirects #232.

Users who are eager for interceptors can also opt-in to this feature and start experimenting if they can't wait for stabilization.

Related: #42

@codecov
Copy link

codecov bot commented Jul 16, 2020

Codecov Report

Merging #206 into master will decrease coverage by 0.58%.
The diff coverage is 25.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
- Coverage   71.68%   71.09%   -0.59%     
==========================================
  Files          42       44       +2     
  Lines        2137     2128       -9     
==========================================
- Hits         1532     1513      -19     
- Misses        605      615      +10     
Impacted Files Coverage Δ
src/cookies/mod.rs 83.60% <0.00%> (-1.40%) ⬇️
src/interceptor/mod.rs 0.00% <0.00%> (ø)
src/interceptor/obj.rs 0.00% <0.00%> (ø)
src/lib.rs 75.00% <ø> (ø)
src/interceptor/context.rs 30.00% <30.00%> (ø)
src/client.rs 66.35% <54.54%> (-2.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97d5e3c...dc500f5. Read the comment docs.

@sagebind sagebind marked this pull request as ready for review October 11, 2020 01:48
@sagebind sagebind merged commit 6b7bd12 into master Oct 11, 2020
@sagebind sagebind deleted the interceptors branch October 11, 2020 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant