1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-28 04:55:37 -05:00

feat: export (const.)core.v2rayKey (#831)

* comment on.

* rename to V2rayKeyValue
This commit is contained in:
rurirei
2021-04-02 18:41:17 +08:00
committed by GitHub
parent d2a51b9b39
commit 102e32957a
2 changed files with 4 additions and 3 deletions

View File

@@ -9,11 +9,12 @@ import (
// V2rayKey is the key type of Instance in Context, exported for test.
type V2rayKey int
const v2rayKey V2rayKey = 1
// V2rayKeyValue is the key value of Instance in Context, exported for test.
const V2rayKeyValue V2rayKey = 1
// FromContext returns an Instance from the given context, or nil if the context doesn't contain one.
func FromContext(ctx context.Context) *Instance {
if s, ok := ctx.Value(v2rayKey).(*Instance); ok {
if s, ok := ctx.Value(V2rayKeyValue).(*Instance); ok {
return s
}
return nil