http-rs / surf

Fast and friendly HTTP client framework for async Rust
https://docs.rs/surf
Apache License 2.0
1.45k stars 119 forks source link

feat: add per-request middleware #266

Closed Fishrock123 closed 3 years ago

Fishrock123 commented 3 years ago

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 https://github.com/http-rs/surf/issues/261