Replace middleware API with interceptors API #206
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.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.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