Comments (8)
Right but why can't your customer define in configuration:
micronaut.http.services.client1.url=http://localhost
Then filter:
@ClientFilter(serviceId="client1")
public class ClientInterceptor1 {
@RequestFilter
@ExecuteOn(TaskExecutors.BLOCKING)
public void filterRequest(MutableHttpRequest<?> request) {
// some logic
}
}
Then inject:
@Inject @Client("client1") HttpClient client;
from micronaut-core.
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
from micronaut-core.
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 HttpClient
instance and there is no way to avoid that, is that right ?
Thanks
from micronaut-core.
you are creating the client yourself manually, so that is bypassing any filters we would usually inject
from micronaut-core.
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 ?
from micronaut-core.
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?
from micronaut-core.
Reason why client filter @ClientFilter(Filter.MATCH_ALL_PATTERN)
with pattern matching cannot be used:
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 HttpClient
with different interceptors/filters association requirement comes in. If micronaut supports associating the HttpClient
with respective filter, we can ask enduser to use our HttpClient
bean created in library and for other uses, use default HttpClient
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.
from micronaut-core.
Hi @graemerocher,
I think the solution provided perfectly fits our requirement. Thank you on that!
Regards,
Bharath
from micronaut-core.
Related Issues (20)
- Can't find micronautserviceconfigs when running as jlink-ed application HOT 9
- Http filter recieves null response in a case of an error HOT 2
- "Multiple possible bean candidates found" error in IntelliJ HOT 1
- StreamingFileUpload with Multipart Form Data materialises in RAM when QueryParam is used in Controller and query param is not sent
- Minecraft Error I think it has something to do with the new java update? HOT 2
- Micronaut Cors does not work as expected when we define custom HttpServerFilters HOT 6
- Code generated with `@Around` does not retain (?) visibility modifier of original class
- Action Required: Fix Renovate Configuration
- Micronaut not picking up spring @RestController apis defined in 3rd party spring boot jar
- Graal annotation processor doesn't mark package-private injected fields for reflective access HOT 1
- Connection closed before response was received on concurrent requests HOT 1
- Micronaut v4.3.1 causing stackoverflow exception on java compilation HOT 3
- @RequestScope cannot be used with HTTP client blocking requests HOT 7
- Instantiation methods in introspection of abstract class tries to instantiate the abstract class
- NoSuchMethodError/KSP generated bean definition constructor missing parameters for class with AOP advice HOT 2
- Non-nullable Long Kotlin data class field initialized with 0 when field is missing in payload
- After upgrading to 4.4.0 missing Kotlin data class non nullable String values cause a NPE HOT 1
- While upgrading to micronuat 4.4 from 3.8 HTTPResponse Body content is in unpooledContent and body is null HOT 6
- Rendering issue in docs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micronaut-core.