|
StripeKit 0.1.1
Stripe integration toolkit for C++
|
Sends StripeKit's requests to Stripe. More...
#include <HTTPClient.h>
Public Types | |
| using | Completion = std::function<void(std::variant<HttpResponse, std::exception_ptr>)> |
| Completion callback for the callback form of send(). | |
Public Member Functions | |
| virtual | ~HTTPClient ()=default |
| Destroys the HTTP client instance. | |
| virtual Task< HttpResponse > | send_async (const HttpRequest &request)=0 |
| Sends a request to Stripe. | |
| virtual void | send (const HttpRequest &request, Completion completion)=0 |
| Sends a request to Stripe, reporting the result through a callback. | |
Sends StripeKit's requests to Stripe.
This is the outbound half of an adapter. Implement it to put StripeKit on top of an existing HTTP stack; applications normally use a ready-made adapter such as stripekit::drogon::HTTPClient instead.
A rejected request is not an error here. Report a 4xx or 5xx from Stripe as a normal HttpResponse and let StripeKit parse Stripe's error document and throw StripeApiException itself. Reserve exceptions for failures that stopped the request reaching Stripe at all, such as DNS, TLS, or timeout failures.
Implementations must be thread-safe and must tolerate several requests being in flight at once.
Definition at line 110 of file HTTPClient.h.
| using stripekit::HTTPClient::Completion = std::function<void(std::variant<HttpResponse, std::exception_ptr>)> |
Completion callback for the callback form of send().
Definition at line 113 of file HTTPClient.h.
|
virtualdefault |
Destroys the HTTP client instance.
Reimplemented in stripekit::drogon::HTTPClient.
|
pure virtual |
Sends a request to Stripe.
| request | What to send, including the options to honour. |
| std::exception | Stripe could not be reached. A response with an error status is returned normally, not thrown. |
Implemented in stripekit::drogon::HTTPClient.
|
pure virtual |
Sends a request to Stripe, reporting the result through a callback.
The callback must be invoked exactly once, on every path including the failure paths. Calling it twice corrupts whatever is waiting on it; never calling it hangs the request. OnceCallback exists to enforce this.
| request | What to send, including the options to honour. |
| completion | Receives Stripe's response, or the transport failure. |
Implemented in stripekit::drogon::HTTPClient.