Skip to content
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

feat(transport/http): remove wrapper.w and add Unwrap method for acce… #3189

Closed
wants to merge 4 commits into from

Conversation

kvii
Copy link
Contributor

@kvii kvii commented Feb 4, 2024

Description (what this PR does / why we need it):

  1. Remove wrapper.w to avoid confused of ResponseWriter.
  2. Add unwrap method for accessing wrapped ResponseWriter.
  3. Create testing code for wrapper.Result.

Now users can use followed code to get custom ResponseWriter they passed:

if u, ok := w.(interface { Unwrap() http.ResponseWriter }); ok {
	if cw, ok := w.Unwrap().(*CustomResponseWriter); ok {
		// do something with CustomResponseWriter
	}
}

Which issue(s) this PR fixes (resolves / be part of):

fixes/resolves #3174

Other special notes for the reviewers:

Rename "responseWriter" to "wrappedWriter" for better semantics.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 4, 2024
@codecov-commenter
Copy link

codecov-commenter commented Feb 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c7fa51d) 84.62% compared to head (33531fb) 84.60%.

❗ Current head 33531fb differs from pull request most recent head 582e3ee. Consider uploading reports for the commit 582e3ee to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3189      +/-   ##
==========================================
- Coverage   84.62%   84.60%   -0.02%     
==========================================
  Files          88       88              
  Lines        3993     3988       -5     
==========================================
- Hits         3379     3374       -5     
  Misses        440      440              
  Partials      174      174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kvii kvii closed this Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to customize http.ResponseWriter because of wrong implementation of Kratos' http.wrapper.Result()
2 participants