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.