Skip to content

Exclude by default content-types !== 'text/html'#19

Closed
belgattitude wants to merge 2 commits into
php-middleware:masterfrom
belgattitude:fix/json
Closed

Exclude by default content-types !== 'text/html'#19
belgattitude wants to merge 2 commits into
php-middleware:masterfrom
belgattitude:fix/json

Conversation

@belgattitude

Copy link
Copy Markdown

see #18

@belgattitude

Copy link
Copy Markdown
Author

@snapshotpl, here's a little P/R for JsonResponse. Actually I think I should be the default for all content-types !== 'text/html'

Let me know what you think. This P/R is more for discussion.

See also: #18

Comment thread src/PhpDebugBarMiddleware.php Outdated
* @param DebugBarRenderer $debugbarRenderer
* @param bool $excludeNonHtmlContent Whether to disable debugbar on content-types != 'test/html'
*/
public function __construct(DebugBarRenderer $debugbarRenderer, $excludeNonHtmlContent=true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Default value change current behaviour. Can we stay as is by default?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For my part, yes


if ($this->isHtmlResponse($response)) {
return $this->attachDebugBarToResponse($response);
} elseif ($this->excludeNonHtmlContent) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Missing test case

Comment thread src/PhpDebugBarMiddleware.php Outdated
protected $excludeNonHtmlContent;

/**
* PhpDebugBarMiddleware constructor.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Useless information - to remove

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

phpstorm ;)


public function __construct(DebugBarRenderer $debugbarRenderer)
/**
* @var bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe will be better to have some policy for that? Sometimes you want to debug json, but not generated pdf. With bool it's not possible. We can provide some read implmentation and simple interface to provide own.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agree... not sure if I can get some time to think about it. We could add a special key '__debugbar' if it does not already exist . But I believe, going content-type-aware will need some more refactoring.

@snapshotpl

Copy link
Copy Markdown
Member

And as you see tests are broken ;(

@belgattitude

Copy link
Copy Markdown
Author

@snapshotpl I've fixed the tests by setting default excludeNonHtmlContent to false... But then Json is broken again then.

I'm not sure that I can fix the current behaviour, would need probably some breaking changes, but for sure refactoring of the middleware.

I let the P/R living here, but good if you can find a better fix

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.

2 participants