mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-27 07:59:47 +00:00
24 lines
411 B
Go
24 lines
411 B
Go
|
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)
|
||
|
}
|