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

[FEATURE] expose newConn function for custom Upgrader #914

Closed
1 task done
adhocore opened this issue May 1, 2024 · 2 comments
Closed
1 task done

[FEATURE] expose newConn function for custom Upgrader #914

adhocore opened this issue May 1, 2024 · 2 comments

Comments

@adhocore
Copy link

adhocore commented May 1, 2024

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

@adhocore
Copy link
Author

adhocore commented May 1, 2024

(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.

@adhocore
Copy link
Author

adhocore commented May 2, 2024

ok seeking alternative ws then. theres no point pursuing here any further.

@adhocore adhocore closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
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

No branches or pull requests

1 participant