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

feat: add per-request middleware #266

Merged
merged 1 commit into from
Feb 11, 2021

Conversation

Fishrock123
Copy link
Member

@Fishrock123 Fishrock123 commented Nov 21, 2020

I think Tide & Surf's focus on ergonomics predicates this should happen, even if it's not the most efficient.
Were it for efficiency alone we would not have the top-level http-verb quick methods.
Hopefully the notice in the docs will put people in the correct direction for most cases.

This adds an optional middleware stack to Request, allowing RequestBuilder and one-off requests to have middleware added onto them, but also allows one-off requests with middleware to have the middleware stack be appended to client middleware for just that request.

Closes #261

This adds an optional middleware stack to `Request`, allowing
`RequestBuilder` and one-off requests to have middleware added
onto them, but also allows one-off requests with middleware to
have the middleware stack be appended to client middleware
for just that request.
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

This looks really good! I think all this PR is missing is a test to ensure the per-request middleware is constructed correctly, and does not accidentally modify the client middleware. But 💯 work!

@@ -177,6 +177,8 @@ impl Client {

/// Send a `Request` using this client.
///
/// Client middleware is run before per-request middleware.
Copy link
Member

Choose a reason for hiding this comment

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

nice; I think this clarification will be helpful

@Fishrock123 Fishrock123 merged commit 651b82f into http-rs:main Feb 11, 2021
@Fishrock123 Fishrock123 deleted the per-request-middleware branch February 11, 2021 23:56
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.

Per-request middleware? (in RequestBuilder)
2 participants