-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Is your feature request related to a problem? Please describe it.
When using ConditionalInterceptor.Subject
it's currently only possible to target .all
, .services
, or .methods
.
This makes it difficult to express common cases like "apply this interceptor to all methods except a small set" without manually listing every included method or service. For example applying authentication everywhere except health check and authentication services.
Describe the solution you'd like
-
Negative variants
Add negative forms alongside the existing.services
/.methods
, for example:.exceptServices(Set<ServiceDescriptor>) .exceptMethods(Set<MethodDescriptor>)
This would keep the current per-scope structure but add the ability to exclude instead of include.
-
Unified include/exclude
Alternatively or additionally, introduce single cases that accept both services and methods at once:.only(services: Set<ServiceDescriptor> = [], methods: Set<MethodDescriptor> = []) .except(services: Set<ServiceDescriptor> = [], methods: Set<MethodDescriptor> = [])
This keeps the API minimal, avoids combining multiple subjects, and makes it easy to mix service-level and method-level rules.
-
Predicate-based matching
Additionally add a form such as:.predicate(@Sendable (MethodDescriptor) -> Bool)
The library already caches interceptor lists per method (for what I understand), so the predicate should be pure/static (same result for a given method, not dependent on runtime state).
This would fill the gap for complex inclusion/exclusion logic and avoid introducing heavier mechanisms like arrays of subjects with combination rules.
If you already have ideas or internal discussions about expanding
Subject
matching in a different way, I'd be interested to hear your thoughts.
Describe alternatives you've considered
Manually enumerating all "included" services or methods except the few to be excluded. This works but it's error-prone and hard to maintain, especially when new services or methods are added.
Additional context
I'd be happy to open a PR for this once we agree on the desired semantics and API shape.