-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Resteasy Reactive: Ignore JAX-RS Resource method field thanks to custom logic #39979
Comments
/cc @FroMage (resteasy-reactive), @geoand (resteasy-reactive), @stuartwdouglas (resteasy-reactive) |
I'd like to see a draft PR of what you have in mind |
… by user [ResteasyReactiveProcessor inits skipMethodParameter if there is a predicate annotated with @RestEasyParamsFilter by user. This allows to ignore params chosen by user logic marking them as SKIPPED in order to use different annotated params with respect JAXRS api]
… by user [ResteasyReactiveProcessor inits skipMethodParameter if there is a predicate annotated with @RestEasyParamsFilter by user. This allows to ignore params chosen by user logic marking them as SKIPPED in order to use different annotated params with respect JAXRS api]
… by user [ResteasyReactiveProcessor inits skipMethodParameter if there is a predicate annotated with @RestEasyParamsFilter by user. This allows to ignore params chosen by user logic marking them as SKIPPED in order to use different annotated params with respect JAXRS api]
The part of init of predicate could be implemented better, I guess. Any advice could help. BTW, it should be a draft for proposal. In particular, for cases like
A rest easy method like this could be indexed skipping (in this case) param annotated with @prompt, but using benefits of jax rs api. The skipped param will be in generale handled by other logic (interceptor and other stuff) to provide implementation of framework
Note that these kind of skips should be used only inside an extension deployment definition, because is a logic that is decided by the framework that user is importing, on top of jaxrs. If you compare the implementation inside PR, you see that I have reused your SKIPPED logic instead edit extractParameterInfo logic as I said before; the result is the same as expected |
Feature introduced with #40031 |
Description
In order to provide an augmentation of JAX-RS API, it would be nice if we could ignore a field as it was an un-annotated fields: so “field” variable result would be the result of evaluation of custom predicate/service defined by user, here the snippet I'm referring
Why this? This is my use case:
I’ll try to define new kind of API built on top of JAX-RS. These API allow to inject inside the signature of JAX-RS resource method, some entities provided by some logic under the hood before actual invocation of method.
Why not a
@Context
as alternative to define custom field? Because these API are part of set of new API that have a specific semantic with respect JAX-RS, so it is a high level specification that don’t needs JAX-RS.To go in depth of my domain use case, the new framework I’m designing provides APIs to design chatbot. Every chatbot needs to define a set of intents. Every intent matches a specific REST routing, but needs injection of some chatbot context entities.
These APIs are an orthogonal specification with respect JAX-RS, but the implementation chosen is using JAX-RS baseline to inherits features that we need to guarantees the expected behavior, so
@Context
would be not acceptable as alternative.Chatbot is new kind of interface that combines some features inherited by REST API definition (like using same http protocols) and some new add-on concepts.
This feature allows to enrich JAX-RS layer and will fix this current problem
This kind of method throws "Resource method " + info + " can only have a single body parameter" exception because "field" is constant to false and the builder set
So the type it will be not null and throws exception because there is more then one field.
Implementation ideas
To implement this feature
"field" param is constant to false, so I would like to replace it with a function result, adding a predicate like this
private Predicate<Map<DotName, AnnotationInstance>> skipMethodParameter = null;
. I see that is done only for reactive rest client purpose with respect NotBody annotation. This predicate will be init during build phase of deployment processor with a custom bean defined by user. Then I could use a custom definition to decide how to skip a field as it was a un-unnotated fieldThe text was updated successfully, but these errors were encountered: