halforbit / api-client Goto Github PK
View Code? Open in Web Editor NEWEasily define and execute web requests with strong request and response types, and a simple fluent interface.
License: MIT License
Easily define and execute web requests with strong request and response types, and a simple fluent interface.
License: MIT License
Today when an unexpected HTTP response code is encountered, ApiClient throws an ApiRequestException
.
While this exception is rich with properties about the request and the response, if the server includes a text response body (often containing an error message), this is not easily surfaced. A work-around today is to catch the ApiRequestException
and use its Response
to get the text content, but we can probably do better.
Also, Response
contains an ErrorMessage
property that is only populated under some circumstances, and particularly not when an unexpected response code is encountered.
On an unexpected response code, let's try to interrogate the response body (if there is one) as text, and include that text in both the Message
property of the exception as well as the ErrorMessage
property.
curl
has a concise and widely adopted format for describing web requests. Not only can a curl
command be run at the command prompt, but Postman allows importing curl
commands for a rich experience.
If we could furnish developers with a curl
command that precisely describes their request, they could easily reproduce the request with the tool of their choice.
Let's add a property to the Response
type for retrieving a curl
command.
This feature might need to be opt-in, since if there is a request body we will need to retain it fully in memory in some form to be able to include its content in the curl command.
Today HTTP 429 is not included in the default list of retryable status codes, but it should be. So let's add it.
This article outlines the motivations for the move:
https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
Unfortunately, this is only supported in .NET Core 2.1+, so to retain backwards compatability, this will need to be switched off of target framework, with legacy .NET Framework 4.x continuing to use the existing pattern.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.