Releases: scottoffen/fluenthttpclient
3.0.5
What's Changed
- Renamed the static class for global options to
FluentHttpClientOptionsby @scottoffen in #19
Full Changelog: 3.0.4...3.0.5
3.0.4
- Enables nullable in the csproj
- Adds an extension methods for
.WithQueryParamthat takes nullable objects. If the object is null, an empty string is added. If the object is not null, adds the result ofToString() - Adds an extension method
HttpClient.WithoutRoute(), set's the route to an empty string
3.0.3
3.0.2
Adds target for .Net 8.0
This version now targets .Net 6.0, .Net 7.0 and .Net 8.0
#8 Trailing Slashes Should Not Be Added When Route Is Empty
Fixes issue where trailing slash was being added if no value was provided for Route.
To intentionally include a trailing slash, use a slash for the route instead of leaving it blank.
client.UsingRoute(); // no trailing slash
client.UsingRoute("/"); // includes trailing slash#7 Add HttpRequestException Handler
You can now fluently add an exception handler for HttpRequestException. When not used, the exception will be thrown without any behavior change. When used, the handler is called and a NullHttpResponseMessage object is returned with a StatusCode of 0. The handler must be added before the request is sent.
var response = await _client
.UsingRoute("/user/list")
.WithQueryParam("sort", "desc")
.OnHttpRequestException(ex => { /* exception handling code here */ })
.GetAsync()
.OnFailure(msg => { success = false; })
.OnSuccess(msg => { success = true; });This will only handle exceptions of type
HttpRequestException. All other exception will be unhandled.
An extension method HttpRequestExceptionOccurred on HttpResponseMessage will return true if the object is the subclass NullHttpResponseMessage. You do not need to check this in the OnSuccess nor OnFailure handlers, as neither OnSuccess nor OnFailure handlers will be called when the exception hander is used and an exception is throw, as both of those methods are specific to the response from the external service.
2.1.0
- Drops .NetStandard 2.0 target framework
- Adds .NET 7.0 target framework
- Adds support for XML deserialization
- Changes default value of
suppressExceptionto true
1.4.0
Merge pull request #1 from scottoffen/add-json-extensions Improve JSON support