mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-28 00:42:37 -04:00
25 lines
421 B
Go
25 lines
421 B
Go
package proxy
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type requestContextKey string
|
|
|
|
const (
|
|
serviceIdKey requestContextKey = "serviceId"
|
|
)
|
|
|
|
func withServiceId(ctx context.Context, serviceId string) context.Context {
|
|
return context.WithValue(ctx, serviceIdKey, serviceId)
|
|
}
|
|
|
|
func ServiceIdFromContext(ctx context.Context) string {
|
|
v := ctx.Value(serviceIdKey)
|
|
serviceId, ok := v.(string)
|
|
if !ok {
|
|
return ""
|
|
}
|
|
return serviceId
|
|
}
|