mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 12:27:37 +03:00
22 lines
510 B
Go
22 lines
510 B
Go
package pause
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/sagernet/sing/service"
|
|
)
|
|
|
|
func ManagerFromContext(ctx context.Context) Manager {
|
|
return service.FromContext[Manager](ctx)
|
|
}
|
|
|
|
func ContextWithManager(ctx context.Context, manager Manager) context.Context {
|
|
return service.ContextWith[Manager](ctx, manager)
|
|
}
|
|
|
|
func ContextWithDefaultManager(ctx context.Context) context.Context {
|
|
if service.FromContext[Manager](ctx) != nil {
|
|
return ctx
|
|
}
|
|
return service.ContextWith[Manager](ctx, NewDefaultManager(ctx))
|
|
}
|