Hey @ploeh
Some advanced DI usage scenarios aren’t that easy to support by the DI abstraction (e.g. providing context to the resolution process), so I can’t come up with a much smoother way of achieving what you want using DI right now besides the ideas you’ve probably already explored.
A more flexible approach would be to not use DI in the first place but make use of the context we’re passing down in the pipeline. In your behavior you’d use something like:
context.Extensions.Set(httpClient);
and in your handler you can retrieve the client using:
context.Extensions.Get<HttpClient>();
This is fully testable but it requires you to setup the HttpClient in the test context instead of just passing it in the constructor though.