-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple client filters in Micronaut #10881
Comments
what you are trying to do is not supported. See https://docs.micronaut.io/4.4.10/guide/#clientFilter section "Filter Matching By Annotation" on how to achieve what you are trying to achieve |
Hi @graemerocher, Thanks for the response. I have went through the documentation already. Not supported meaning: client filters are applied to ALL outgoing requests invoked via Thanks |
you are creating the client yourself manually, so that is bypassing any filters we would usually inject |
We have Springboot based application microservices and it supports specific filter/interceptor association to RestTemplate (http client) bean. Can I create a feature request for this to support in micronaut ? |
I am failing to see from your example why you need to explicitly create the client and why the section "Filter Matching By Annotation" on the documentation does not meet your requirement. Can you explain why? |
Reason why client filter We have created a micronaut library which will be used by micronaut application microservices. So, within library, we have created filters which does some business operations for every outgoing request. Now, when the enduser application uses our library, they will have some outgoing requests other than the one which needs filter and some requets which does not need filters to be applied. Since micronaut applies filter for all the requests, our library filters will be applied for all of it. Which is not intended. That's where the requirement of Now, coming to pattern matching, as this is library, we cannot restrict with a URL pattern hardcoding in library. If you think of any other way to achieve this is micronaut, please let me know. Thanks. |
Right but why can't your customer define in configuration:
Then filter: @ClientFilter(serviceId="client1")
public class ClientInterceptor1 {
@RequestFilter
@ExecuteOn(TaskExecutors.BLOCKING)
public void filterRequest(MutableHttpRequest<?> request) {
// some logic
}
} Then inject:
|
Hi @graemerocher, I think the solution provided perfectly fits our requirement. Thank you on that! Regards, |
Issue description
I have a micronaut service which has two filters with
@Named
annotation set to unique values. Without@Named
annotation on HttpClient, filters work fine. But, with@Named
annotation, it does not work. In simple@ClientFilters
class definition is applied to all the client requests globally.Requirement is to have multiple
ClientFilters
classes and eachHttpClient
injection should be associated to only specific filter definition.Note: URL Pattern matching is one option for each filter, but in this case URL pattern is not known or dynamic.
Thanks
So far, I tried this and filter class is not getting applied when I use
@Named
annotation inHttpClient
class as shown in below code snippetsBean to provide the HttpClient Configuration
And a service class
The text was updated successfully, but these errors were encountered: