Add loopback check

This commit is contained in:
世界
2023-04-08 08:58:01 +08:00
parent 62425ad3e4
commit 6843970536
9 changed files with 73 additions and 35 deletions

14
outbound/lookback.go Normal file
View File

@@ -0,0 +1,14 @@
package outbound
import "context"
type outboundTagKey struct{}
func ContextWithTag(ctx context.Context, outboundTag string) context.Context {
return context.WithValue(ctx, outboundTagKey{}, outboundTag)
}
func TagFromContext(ctx context.Context) (string, bool) {
value, loaded := ctx.Value(outboundTagKey{}).(string)
return value, loaded
}