saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.09k stars 107 forks source link

Feature | V3 Debugging Helper Methods #284

Closed Sammyjo20 closed 1 year ago

Sammyjo20 commented 1 year ago

This PR attempts to simplify the debugging helpers we previously had by making them a small wrapper around our middleware system. Now, when you want to debug a request or a response, you can simplify call the debugRequest or debugResponse method and provide it a callable.

This callable will be provided a PendingRequest and PSR-7 request if you're using debugRequest .

$connector->debugRequest(function (PendingRequest $pendingRequest, RequestInterface $psrRequest) {
     //
});

This callable will be provided a Response and PSR-7 response if you're using debugResponse.

$connector->debugResponse(function (Response $response, ResponseInterface $psrResponse) {
     //
});