-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
Simpler solution to provide hints #1170
Conversation
/** | ||
* @author Sebastien Deleuze | ||
*/ | ||
public class JacksonHintsIntegrationTests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class will be removed from the commit before going to master, it was not intended to be here.
af7d6a2
to
6f4db91
Compare
This looks simple enough but for JSONP and for HTTP ranges (very likely) we'll also need access to the request. At that point however it is no longer symmetric between client and server and only applies to the server. Perhaps a variation on this PR could be a This would allow all places to still accept an |
@rstoyanchev Good points, I will update the PR accordingly. |
6f4db91
to
0f22d2e
Compare
@rstoyanchev I have pushed updated commits, could you please have a look? |
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.web.reactive.result.method.annotation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this class is in the spring-web-reactive
module, I'm afraid SPR-14664 won't use this because ResourceHttpMessageWriter
is in the spring-web
module, org.springframework.http.codec
package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServerHttpMessageWriter
is generally useful for sever-side use. As such I see it as belonging in spring-web next to HttpMessageWriter
where we also have other server-side only writers like the one for Server-Sent Events.
The ResourceHttpMessageWriter
needs it and that's another confirmation it should be there. It would be needed for JSONP as well and anything else that needs access to the request to prepare hints.
As for the MethodParameter
couldn't we make that a ResolvableType
, call it streamType
, and order it ahead of elementType
in the method signature? That would be a little less assuming that there is a MethodParameter
necessarily.
I would also de-emphasize that it's for controllers only in the Javadoc. It's for server-side use first and foremost, certainly in controllers. The Jackson implementations could also be in spring-web by the way as far as I can see so it's all together.
In addition to moving to spring-web I see two more things to improve. There is no way to apply more than one of these (e.g. JsonView + JSONP). Perhaps instead of extending Two this doesn't yet cover the case of the |
Issue: SPR-14693
Issue: SPR-14693
0f22d2e
to
49b1680
Compare
To be honest, I never really understood the need for the |
Indeed + that allows to use that mechanism with the SSE reader/writer too. I have updated the commit accordingly, is it ok for you (not sure if the remaining point you raised about |
Comparable to what |
public List<MediaType> getWritableMediaTypes() { | ||
return this.writer.getWritableMediaTypes(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this pre-implement resolveHints to do delegation to the next HttpMessageWriter
if it is a ServerHttpMessageWriter
and then invoke some resolveHintsInternal
abstract protected method? I don't see that last bit right now that would allow decorating with more than one ServerHttpMessageWriter
.
Same comment for the HttpMessageReader
too.
This looks good now @sdeleuze. For the |
Merged |
As proposed by @rstoyanchev, here is a draft PR that allow to provide hints without implementing
Request/ResponseBodyAdvice
. I have used anObject source
parameter to allow using this mechanism for the HTTP client and the server functional programming model if need, without exposedMethodParameter
in the codec/reader/writer API.Any thoughts?