Skip to content

Commit d3fc968

Browse files
authored
feat: Support SetReadDeadline, SetWriteDeadline and EnableFullDuplex (#29)
1 parent c5817c2 commit d3fc968

File tree

8 files changed

+8434
-349
lines changed

8 files changed

+8434
-349
lines changed

capture_metrics.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ func (m *Metrics) CaptureMetrics(w http.ResponseWriter, fn func(http.ResponseWri
8484
fn(Wrap(w, hooks))
8585
m.Duration += time.Since(start)
8686
}
87+
88+
// deadliner defines two methods introduced in go 1.20. The standard library
89+
// seems not to provide an interface we can import, hence its definition here.
90+
type deadliner interface {
91+
SetReadDeadline(deadline time.Time) error
92+
SetWriteDeadline(deadline time.Time) error
93+
}
94+
95+
// fullDuplexEnabler defines a method introduced in go 1.21. The standard
96+
// library seems not to provide an interface we can import, hence its definition
97+
// here.
98+
type fullDuplexEnabler interface {
99+
EnableFullDuplex() error
100+
}

capture_metrics_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package httpsnoop
22

33
import (
44
"io"
5-
"io/ioutil"
65
"log"
76
"net/http"
87
"net/http/httptest"
@@ -16,7 +15,7 @@ func TestCaptureMetrics(t *testing.T) {
1615
// Some of the edge cases tested below cause the net/http pkg to log some
1716
// messages that add a lot of noise to the `go test -v` output, so we discard
1817
// the log here.
19-
log.SetOutput(ioutil.Discard)
18+
log.SetOutput(io.Discard)
2019
defer log.SetOutput(os.Stderr)
2120

2221
tests := []struct {

codegen/main.go

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)