1
0
Fork 0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-01-11 13:13:32 +02:00
Xray-core/common/protocol/context.go

24 lines
411 B
Go
Raw Normal View History

2020-11-25 13:01:53 +02:00
package protocol
import (
"context"
)
type key int
const (
requestKey key = iota
)
func ContextWithRequestHeader(ctx context.Context, request *RequestHeader) context.Context {
return context.WithValue(ctx, requestKey, request)
}
func RequestHeaderFromContext(ctx context.Context) *RequestHeader {
request := ctx.Value(requestKey)
if request == nil {
return nil
}
return request.(*RequestHeader)
}