sing/service/pause/context.go
2023-08-07 16:02:48 +08:00

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))
}