Releases: justeattakeaway/httpclient-interception
Releases · justeattakeaway/httpclient-interception
JustEat.HttpClientInterception v1.2.0
Overview
This version adds various changes to make it easier to intercept requests based on arbitrary conditions you provide, as well as to ignore the hostname and/or path for requests.
It also adds some new methods to make the fluent API for HttpRequestInterceptionBuilder easier to use.
Thanks to @stephenthrelfall for raising the issue (#20) that lead to these changes 👍
Below is an example comparing the previous (and still usable) syntax compared to the new syntax options:
1.0.0+
var builder = new HttpRequestInterceptionBuilder()
.ForHost("public.je-apis.com")
.ForPath("terms")
.WithJsonContent(new { Id = 1, Link = "https://www.just-eat.co.uk/privacy-policy" });
var options = new HttpClientInterceptorOptions()
.Register(builder);1.2.0+
var options = new HttpClientInterceptorOptions();
var builder = new HttpRequestInterceptionBuilder()
.Requests()
.ForHost("public.je-apis.com")
.ForPath("terms")
.Responds()
.WithJsonContent(new { Id = 1, Link = "https://www.just-eat.co.uk/privacy-policy" })
.RegisterWith(options);Changes
- Support arbitrary request matching using the new
For(Predicate<HttpRequestMessage>)method onHttpRequestInterceptionBuilder. This also adds a complementaryHavingPriority(int?)method that allows multiple different predicates to be registered with a hierarchy. (#21) - Add
Deregister(HttpRequestInterceptionBuilder)convenience method toHttpClientInterceptorOptions. (#21) - Support configuring
HttpRequestInterceptionBuilderto ignore the request hostname by usingForAnyHost(). (#20, #21) - Support configuring
HttpRequestInterceptionBuilderto ignore the request path by usingIgnoringPath(). (#21) - Add
OnMissingRegistrationproperty toHttpClientInterceptorOptionsto allow dynamically building a response for any requests that do not match any registered interceptions. (#20, #21) - Add
RegisterWith(HttpClientInterceptorOptions)extension method toHttpRequestInterceptionBuilderto make it easier to chain multiple registrations fluently. (#21) - Add no-op
Requests()andResponds()extension methods toHttpRequestInterceptionBuilderwhich can be used to make fluent usage of the type more expressive in intent. (#21)
Contributors
JustEat.HttpClientInterception v1.1.0
Changes
- Support conditional request interception (#9)
- Add option to ignore query strings (#10)
- Add convenience overload methods for registering multiple interceptions at once (#11, #13)
- Documentation and example improvements (#12, #17)
- Now tested on OS X as part of our continuous integration (#18)
Contributors
JustEat.HttpClientInterception v1.0.0
First release.
Package available on NuGet.