Refactor: make inbound request contextual
This commit is contained in:
@ -27,11 +27,6 @@ const (
|
||||
LoadBalance
|
||||
)
|
||||
|
||||
type ServerAdapter interface {
|
||||
net.Conn
|
||||
Metadata() *Metadata
|
||||
}
|
||||
|
||||
type Connection interface {
|
||||
Chains() Chain
|
||||
AppendToChains(adapter ProxyAdapter)
|
||||
@ -50,6 +45,15 @@ func (c Chain) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (c Chain) Last() string {
|
||||
switch len(c) {
|
||||
case 0:
|
||||
return ""
|
||||
default:
|
||||
return c[0]
|
||||
}
|
||||
}
|
||||
|
||||
type Conn interface {
|
||||
net.Conn
|
||||
Connection
|
||||
|
23
constant/context.go
Normal file
23
constant/context.go
Normal file
@ -0,0 +1,23 @@
|
||||
package constant
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
)
|
||||
|
||||
type PlainContext interface {
|
||||
ID() uuid.UUID
|
||||
}
|
||||
|
||||
type ConnContext interface {
|
||||
PlainContext
|
||||
Metadata() *Metadata
|
||||
Conn() net.Conn
|
||||
}
|
||||
|
||||
type PacketConnContext interface {
|
||||
PlainContext
|
||||
Metadata() *Metadata
|
||||
PacketConn() net.PacketConn
|
||||
}
|
Reference in New Issue
Block a user