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.
23 lines
411 B
23 lines
411 B
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) |
|
}
|
|
|