alyssais / hyper-stub

hyper clients that don't touch the network
https://crates.io/crates/hyper-stub
Mozilla Public License 2.0
11 stars 0 forks source link

Make `proxy_client_fn` generic over response body type? #3

Open dekellum opened 6 years ago

dekellum commented 6 years ago

Or add a new function, if it would otherwise be a breaking change?

Specifically...

Currently in my non-stub (real) hyper server tests, I can use hyper::service::service_fn even when the response body type (body_image::async::UniBodyImage) is different than the request body type (hyper::Body), as in:

https://github.com/dekellum/body-image/blob/master/src/async/tests/server.rs#L245

This works because hyper::server::conn::Http::serve_connection is generic over the response body type and (above linked) service_fn doesn't specify the response body type.

I was hoping to be able to do the same thing with your proxy_client_fn, as the logically corollary to service_fn, but the former is not generic over the response body type.

Could that be changed, either in place or with a new function?

Edit: The hyper-stub rustdoc implies that the proxy_client function is the most flexible, but using that looks (thought I'm not entirely sure) a good deal more complicated?

Thanks for your consideration.