-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make httpClient()
a public, static method
#1810
Conversation
|
1 similar comment
|
* Update generated code (#1793) * Update generated code for v1399 * Update generated code for v1409 * Update generated code for v1412 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> * Bump version to 16.4.0 * Added pull request template (#1797) * Add justfile, remove coveralls, and fix AUTOLOAD in CI (#1801) * add justfile and tweak CI + readme * debug test * Debugging * further debugging * restore original composer json * add more logging * maybe fix ci * Fix typo * fix test naming and pass autoload directly to recipe as arugment * Remove unused logline and fix typo * restore composer * remove extra log line * update justfile * add comments * update ci * revert to gh action * ensure dependencies are installed for format and test recipes (#1802) * Added CONTRIBUTING.md file (#1806) * minor justfile fixes (#1807) * made v2 event class concrete, and changed convertToStripeObject to use it if we cannot find the identified event subclass (#1805) * Update generated code for v1461 * Update generated code (#1804) * Update generated code for v1441 * Update generated code for v1452 * Update generated code for v1455 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> Co-authored-by: helenye-stripe <[email protected]> * Bump version to 16.5.0 * Make `httpClient()` a public, static method (#1810) * Make `httpClient()` a public, static method * Make `streamingHttpClient()` a public, static method * Update generated code for v1467 * Raise a more descriptive error if null bytes are found in the path (#1811) * raise a more descriptive error if null bytes are found in the path * formatting * change error thrown for null byte issues (#1813) * Update generated code for v1472 --------- Co-authored-by: stripe-openapi[bot] <105521251+stripe-openapi[bot]@users.noreply.github.com> Co-authored-by: Jesse Rosalia <[email protected]> Co-authored-by: David Brownman <[email protected]> Co-authored-by: helenye-stripe <[email protected]> Co-authored-by: Helen Ye <[email protected]> Co-authored-by: Johan de Jager <[email protected]>
Why?
I want to do something like this with
ApiRequestor::setHttpClient()
:in tests:
in application code:
If you first execute the
ApiRequestor::setHttpClient
in test, and then afterwards theApiRequestor::setHttpClient()
in application code, then the mocked http client is gone and this goes wrong. What I think would be a nice solution: allow me to decorate the configured http client:And then wherever I configure the logging http client I can instantiate this class decorating the previously configured http client:
Now
LoggingHttpClient
decorates the mock client and things work as intended. It kinda becomes a middleware pattern, and opens the door for other middleware, e.g.:What?
httpClient()
public and staticSee Also
NA