We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
NetConn() net.Conn
1 parent 875ad36 commit 4fbbd19Copy full SHA for 4fbbd19
1 file changed
common/upstream.go
@@ -1,16 +1,25 @@
1
package common
2
3
+import "net"
4
+
5
type WithUpstream interface {
6
Upstream() any
7
}
8
9
+type stdWithUpstreamNetConn interface {
10
+ NetConn() net.Conn
11
+}
12
13
func Cast[T any](obj any) (T, bool) {
14
if c, ok := obj.(T); ok {
15
return c, true
16
17
if u, ok := obj.(WithUpstream); ok {
18
return Cast[T](u.Upstream())
19
20
+ if u, ok := obj.(stdWithUpstreamNetConn); ok {
21
+ return Cast[T](u.NetConn())
22
+ }
23
return DefaultValue[T](), false
24
25
@@ -27,5 +36,8 @@ func Top(obj any) any {
27
36
28
37
return Top(u.Upstream())
29
38
39
40
+ return Top(u.NetConn())
41
30
42
return obj
31
43
0 commit comments