mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-16 06:01:21 +08:00
25 lines
490 B
Go
25 lines
490 B
Go
|
package sing
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/Dreamacro/clash/adapter/inbound"
|
||
|
)
|
||
|
|
||
|
type contextKey string
|
||
|
|
||
|
var ctxKeyAdditions = contextKey("Additions")
|
||
|
|
||
|
func WithAdditions(ctx context.Context, additions ...inbound.Addition) context.Context {
|
||
|
return context.WithValue(ctx, ctxKeyAdditions, additions)
|
||
|
}
|
||
|
|
||
|
func getAdditions(ctx context.Context) []inbound.Addition {
|
||
|
if v := ctx.Value(ctxKeyAdditions); v != nil {
|
||
|
if a, ok := v.([]inbound.Addition); ok {
|
||
|
return a
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|