Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] [External] : Re: @Status Annotation?

What we do in our custom solution currently is we have an addotation at the resource method which does not provide a fixed number but a class. There is a filter in place which instantiates that class, provides it the current reponse, and lets that instance decide what is the right response to actually send instead. The implementation of that class dynamically decides if it just keeps the response as-is, or replaces it - for example, by a static value like in your case. The annotation's default is a class which simply uses another integer field of the annotation as input and using that to replace the return code - effectively doing what you want unless someone explicitly configures the annotation with a different class. That's what I mean with declarative-but-more-flexible. :-)

Something like this (peudo-code for brevity): 

@Rewrite(Class<? implements ResponseRewriter> default StaticReturnCode.class, Object configurationForResponseRewriter)

-Markus


-----Ursprüngliche Nachricht-----
Von: jaxrs-dev [mailto:jaxrs-dev-bounces@xxxxxxxxxxx] Im Auftrag von Santiago Pericasgeertsen
Gesendet: Freitag, 3. September 2021 14:25
An: jaxrs developer discussions
Betreff: Re: [jaxrs-dev] [External] : Re: @Status Annotation?



> On Sep 2, 2021, at 4:54 PM, Markus Karg <markus@xxxxxxxxxxxxxxx> wrote:
> 
> No need for Response is a great thing, we already use fitlers for that but with providers for dynamic code.
> I wonder if we shall really hurry and put in 3.1, my belly says -0. Maybe there are better or more flexible solutions to discuss?

 We are talking about declaratively (instead of programmatically) overriding the default response code in Jakarta REST methods. Can you think of any other “more flexible” solutions? There are other REST frameworks already using a simple annotation like this.

— Santiago

> \-----Ursprüngliche Nachricht-----
> Von: jaxrs-dev [mailto:jaxrs-dev-bounces@xxxxxxxxxxx] Im Auftrag von Santiago Pericasgeertsen
> Gesendet: Donnerstag, 2. September 2021 18:17
> An: jaxrs developer discussions
> Betreff: [jaxrs-dev] @Status Annotation?
> 
> Hi All,
> 
> Trying to get some quick feedback before doing anything. 
> 
> There are some use cases in which the default status return for a resource method that does not return Response needs to be overridden. For example, a POST request that wants to return 201 instead of 200. Of course, you can fix this by returning a Response, but that may not be ideal in all cases (e.g., tools that do static analysis would prefer to see Foo over Response as return type). I believe some impls already support this.
> 
> Shall we try to squeeze this in 3.1?
> 
> — Santiago
> _______________________________________________
> jaxrs-dev mailing list
> jaxrs-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/jaxrs-dev__;!!ACWV5N9M2RV99hQ!ZmqdOyRxHvvEEulDP6fSDO7_fhr4ze6vbSc3dBBdTkXSuXHbUDMn7QGCrUdpILJHSJxVsfZaGw$ 
> 
> _______________________________________________
> jaxrs-dev mailing list
> jaxrs-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit https://urldefense.com/v3/__https://www.eclipse.org/mailman/listinfo/jaxrs-dev__;!!ACWV5N9M2RV99hQ!ZmqdOyRxHvvEEulDP6fSDO7_fhr4ze6vbSc3dBBdTkXSuXHbUDMn7QGCrUdpILJHSJxVsfZaGw$ 

_______________________________________________
jaxrs-dev mailing list
jaxrs-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jaxrs-dev



Back to the top