mirror of https://github.com/XTLS/Xray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
411 B
24 lines
411 B
4 years ago
|
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)
|
||
|
}
|