305
CHAPTER 7 | Implement resilient applications
int
? page,
[FromQuery]
string
errorMsg)
{
var
itemsPage =
10
;
var
catalog = await _catalogSvc.
GetCatalogItems
(page ??
0
,
itemsPage,
BrandFilterApplied,
TypesFilterApplied);
//… Additional c
ode
}
}
}
Up to this point, the above code snippet only shows the example of performing regular HTTP
requests. But the ‘magic’ comes in the following sections where it shows
how all the HTTP requests
made by
HttpClient
can have resilient policies such as retries with exponential backoff, circuit
breakers, security
features using auth tokens, or even any other custom feature. And all of these can
be done just by adding policies and delegating handlers to your registered Typed Clients.
Additional resources
•
HttpClient guidelines for .NET
https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines
•
Dostları ilə paylaş: