gobwas / ws

Tiny WebSocket library for Go.
MIT License
6.1k stars 373 forks source link

Hijack connection through `http.ResponseController` in http upgrader #181

Closed xakep666 closed 1 year ago

xakep666 commented 1 year ago

Go 1.20 introduced new and more convenient way to control response and discover features - ResponseController. It's methods can introspect middlewares implementing following interface

type rwUnwrapper interface {
    Unwrap() ResponseWriter
}

source

This PR contains changes to use it if go version newer than 1.20. Old behaviour will be used if go version is older than 1.20.

xakep666 commented 1 year ago

@cristaloleg done

cristaloleg commented 1 year ago

Thanks @xakep666 I will tag 1.3.0 a bit later today.

cristaloleg commented 1 year ago

And done https://github.com/gobwas/ws/releases/tag/v1.3.0

jvilhuber commented 1 year ago

Note go 1.21 is out, so the test "!go1.20" for go 1.19 is no longer correct.

xakep666 commented 1 year ago

@jvilhuber "go 1.20", means "go 1.20 or newer" so negated one is "go 1.19 or older"

jvilhuber commented 1 year ago

Thanks! Learned something new today!