Skip to content

Commit 1d80cf3

Browse files
committed
Final doc fixes
1 parent 2dc66c3 commit 1d80cf3

File tree

6 files changed

+4
-15
lines changed

6 files changed

+4
-15
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ go get nhooyr.io/websocket
1616
- First class [context.Context](https://blog.golang.org/context) support
1717
- Fully passes the WebSocket [autobahn-testsuite](https://github.com/crossbario/autobahn-testsuite)
1818
- Thorough tests with [90% coverage](https://coveralls.io/github/nhooyr/websocket)
19-
- [Zero dependencies](https://pkg.go.dev/nhooyr.io/websocket?tab=imports)
19+
- [Minimal dependencies](https://pkg.go.dev/nhooyr.io/websocket?tab=imports)
2020
- JSON and protobuf helpers in the [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) and [wspb](https://pkg.go.dev/nhooyr.io/websocket/wspb) subpackages
2121
- Zero alloc reads and writes
2222
- Concurrent writes

accept.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func accept(w http.ResponseWriter, r *http.Request, opts *AcceptOptions) (_ *Con
134134
b, _ := brw.Reader.Peek(brw.Reader.Buffered())
135135
brw.Reader.Reset(io.MultiReader(bytes.NewReader(b), netConn))
136136

137-
c := newConn(connConfig{
137+
return newConn(connConfig{
138138
subprotocol: w.Header().Get("Sec-WebSocket-Protocol"),
139139
rwc: netConn,
140140
client: false,
@@ -143,9 +143,7 @@ func accept(w http.ResponseWriter, r *http.Request, opts *AcceptOptions) (_ *Con
143143

144144
br: brw.Reader,
145145
bw: brw.Writer,
146-
})
147-
148-
return c, nil
146+
}), nil
149147
}
150148

151149
func verifyClientRequest(w http.ResponseWriter, r *http.Request) (errCode int, _ error) {

conn_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ func TestWasm(t *testing.T) {
271271
t.Skip("skipping on CI")
272272
}
273273

274-
// TODO grace
275274
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
276275
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
277276
Subprotocols: []string{"echo"},

examples/chat/chat_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func setupTest(t *testing.T) (url string, closeFn func()) {
130130
cs.subscriberMessageBuffer = 4096
131131
cs.publishLimiter.SetLimit(rate.Inf)
132132

133-
// TODO grace
134133
s := httptest.NewServer(cs)
135134
return s.URL, func() {
136135
s.Close()

examples/chat/main.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ func run() error {
3434
log.Printf("listening on http://%v", l.Addr())
3535

3636
cs := newChatServer()
37-
// TODO grace
38-
s := http.Server{
37+
s := &http.Server{
3938
Handler: cs,
4039
ReadTimeout: time.Second * 10,
4140
WriteTimeout: time.Second * 10,

examples/echo/main.go

-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import (
1616
"nhooyr.io/websocket/wsjson"
1717
)
1818

19-
// TODO IMPROVE CANCELLATION AND SHUTDOWN
20-
// TODO on context cancel send websocket going away and fix the read timeout error to be dependant on context deadline reached.
21-
// TODO this way you cancel your context and the right message automatically gets sent. Furthrmore, then u can just use a simple waitgroup to wait for connections.
22-
// TODO grace is wrong as it doesn't wait for the individual goroutines.
23-
2419
// This example starts a WebSocket echo server,
2520
// dials the server and then sends 5 different messages
2621
// and prints out the server's responses.
@@ -34,7 +29,6 @@ func main() {
3429
}
3530
defer l.Close()
3631

37-
// TODO grace
3832
s := &http.Server{
3933
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
4034
err := echoServer(w, r)

0 commit comments

Comments
 (0)