-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Embed the Hijacker interface in intercepting writer #1093
Conversation
Signed-off-by: Arjun Satish <arjun@confluent.io>
transport/http/server.go
Outdated
@@ -226,6 +233,7 @@ type Headerer interface { | |||
|
|||
type interceptingWriter struct { | |||
http.ResponseWriter | |||
http.Hijacker |
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 isn't safe — if this field is nil, h, ok := w.(http.Hijacker)
will succeed, but calling h.Hijack()
will panic, as h
will be nil.
http.Hijacker is one of five common interfaces which http.ResponseWriters are upgraded-to using the interface upgrade pattern — why just solve for this one? |
hey, @peterbourgon thanks very much for the suggestions. yes, it makes sense to accommodate all five interfaces. such a switch case block was what I had in mind for that, but using |
Signed-off-by: Arjun Satish <arjun@confluent.io>
@peterbourgon made the changes. let me know what you think. thanks in advance! |
btw, I'm not very fluent in golang. does the |
Signed-off-by: Arjun Satish <arjun@confluent.io>
@peterbourgon any thoughts on this approach? thanks in advance! |
@peterbourgon what do you think? Can this be merged? 🙏 |
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.
With that change, OK. Not super excited about the additional dependency, but 🤷
transport/http/server.go
Outdated
@@ -5,6 +5,8 @@ import ( | |||
"encoding/json" | |||
"net/http" | |||
|
|||
"github.com/felixge/httpsnoop" | |||
|
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.
Nit: rm the blank line and re-goimports :)
Signed-off-by: Arjun Satish <arjun@confluent.io>
@peterbourgon removed the extra newline. |
@peterbourgon do you think we can merge this now, and release a new tag? many thanks in advance! |
This is a big change to a core package. I'll merge it now, so we can get some beta-testing time, so to speak. |
Oof! What am I saying. Can you please add some tests for this? 😇 |
Happy to re-review with proper test coverage. |
…m stdlib. successor to go-kit#1093 and closes go-kit#1092.
This PR embeds the Hijacker interface in kit's interceptingWriter. Having an hijacker embedding allows applications to use websockets. looks here for discussion around this: golang/go#26937
Addresses issue #1092.