[FEATURE] expose newConn function for custom Upgrader
adhocore opened this issue · 2 comments
Is there an existing feature request for this?
- I have searched the existing feature requests
Is your feature request related to a problem? Please describe.
i was running into a situation where it required newConn() to be exposed. i needed to have a custom Upgrader. however the complexity of unexposed fields in newConn() made wiring it all up impossible.
is it possible to have it exposed as NewConn() or if not what would be the workaround? (previous issue #573)
Describe the solution that you would like.
renaming newConn() to NewConn()
Describe alternatives you have considered.
custom patch with
diff --git a/conn.go b/conn.go
index 221e6cf..9a7fbdd 100644
--- a/conn.go
+++ b/conn.go
@@ -289,6 +289,10 @@ type Conn struct {
newDecompressionReader func(io.Reader) io.ReadCloser
}
+func NewConn(c net.Conn, s bool, r, w int, wp BufferPool, br *bufio.Reader, wb []byte) *Conn {
+ return newConn(c, s, r, w, wp, br, wb)
+}
+
func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {
if br == nil {
Anything else?
No response
(someone seems to have deleted their comments, so i have added back without mentioning them)
Why do you need a custom upgrader? What is the underlying problem that you are trying to solve?
2 cases as to why: for api surfaces unrelated to net/http; for custom requirements/logic in conn upgrades.
most things in Go provide New() as public api for handy usage of struct instantiation so not sure why that has to be secret private api here.
ok seeking alternative ws then. theres no point pursuing here any further.