Skip to content

chore(response_writer): add Unwrap() method to ResponseWriter interface#4506

Open
raju-mechatronics wants to merge 1 commit intogin-gonic:masterfrom
raju-mechatronics:responsewriter/unwrap
Open

chore(response_writer): add Unwrap() method to ResponseWriter interface#4506
raju-mechatronics wants to merge 1 commit intogin-gonic:masterfrom
raju-mechatronics:responsewriter/unwrap

Conversation

@raju-mechatronics
Copy link
Contributor

Description

This PR adds the Unwrap() http.ResponseWriter method to the exported ResponseWriter interface.

Motivation

  • The concrete *responseWriter type already implements Unwrap().
  • However the interface does not declare it.
  • This creates an inconsistency: code that receives a gin.ResponseWriter cannot safely/portably call .Unwrap().
  • Passing the underlying http.ResponseWriter to third-party handlers/middleware (c.Writer.Unwrap())

Adding it to the interface makes usage more idiomatic and type-safe.

// returns underlying http.ResponseWriter
responseWriter := c.Writer.Unwrap()

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.00%. Comparing base (3dc1cd6) to head (1fde324).
⚠️ Report is 275 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4506      +/-   ##
==========================================
- Coverage   99.21%   99.00%   -0.22%     
==========================================
  Files          42       44       +2     
  Lines        3182     3012     -170     
==========================================
- Hits         3157     2982     -175     
- Misses         17       21       +4     
- Partials        8        9       +1     
Flag Coverage Δ
?
--ldflags="-checklinkname=0" -tags sonic 98.99% <ø> (?)
-tags go_json 98.92% <ø> (?)
-tags nomsgpack 98.98% <ø> (?)
go-1.18 ?
go-1.19 ?
go-1.20 ?
go-1.21 ?
go-1.24 99.00% <ø> (?)
go-1.25 99.00% <ø> (?)
macos-latest 99.00% <ø> (-0.22%) ⬇️
ubuntu-latest 99.00% <ø> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raju-mechatronics
Copy link
Contributor Author

@appleboy is this useful? The unwrap function is already implemented. I just exposed it via the ResponseWriter interface.

@appleboy
Copy link
Member

@raju-mechatronics Please write the unit testing.

@appleboy appleboy added this to the v1.13 milestone Mar 21, 2026
@raju-mechatronics
Copy link
Contributor Author

@raju-mechatronics Please write the unit testing.

sure. I'll add the unit tests soon and push the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants