-
Notifications
You must be signed in to change notification settings - Fork 77
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
[fix] httpbp
middleware doesn't flush chunked responses
#573
Merged
kylelemons
merged 9 commits into
reddit:master
from
adamthesax:fix-add-flush-to-httpbp-middleware
Nov 1, 2022
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97c1121
wrapped middleware supports Flush() and Hijack()
49397ad
Update httpbp/middlewares.go
adamthesax 7a442bc
added unit test
08e1879
chain wrapper functions together
193243d
test tweaks
5ad3f18
additional test cases
f3f28de
update to use jump table and support http.Pusher
574ce14
remove generated code and write all wrappers by hand
022d7f1
PR feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔕 it's manage-able as we currently have 2 optional interfaces, it will become a nightmare if there's a 3rd one added in the future. but I also can't find a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this approach is definitely verbose but I can't think of a better one. The only other interface on
http
that ahttp.ResponseWriter
could implement would behttp.Pusher
. I don't think it's worth supporting it now as I don't think we have any use case driving it, but that would be a 3rd interface that may come up in the future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a quietly known issue amongst the ecosystem, and the approach in the generic case seems to be code generation.
https://www.doxsey.net/blog/fixing-interface-erasure-in-go/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the article! I updated this PR to use the approach outlined in the article and included
http.Pusher
. Because we are dealing with 3 interfaces, I adapted their code generator and then massaged the output to make it more human readable. Basically leveraging the jump table idea, without having to adapt a full code generator.@kylelemons let me know if you think is approach is better or if we should revert back to my previous one.