Skip to content

Handled unknown response objects that contain json body #10

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

Merged
merged 1 commit into from
Dec 10, 2018
Merged

Handled unknown response objects that contain json body #10

merged 1 commit into from
Dec 10, 2018

Conversation

MASNathan
Copy link
Contributor

Dingo uses it's custom Response object that, unfortunately, does not extend JsonResponse

The changes that I've made are not limited to Dingo responses, in any Response object has a json content-type (we assume that has a json body) we'll handle the debug workflow as intended.

Hope that can help someone else 😄


$content = $response->getContent();

return json_decode($content, true) ?: false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add json_last_error() check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal here is to 'try' to decode the content, if it fails, we don't need to know the reason, just that it's not a valid json content (this is just to try and guess if it's actually a response with a json content).

If there is no error we do our thing, otherwise, just let it go

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge this! I'm using dingo and it didn't work until I updated debugger.php with this commit.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done )

@mlanin mlanin merged commit 7c27f5d into mlanin:master Dec 10, 2018
@MASNathan MASNathan deleted the handle-unknown-json-response branch December 10, 2018 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants