Allow to specify hints with the functional web API

The most common use case is specifying JSON views.

ServerResponse.BodyBuilder#hint(String, Object) allows to
specify response body serialization hints.

ServerRequest#body(BodyExtractor, Map) allows to specify
request body extraction hints.

Issue: SPR-15030
This commit is contained in:
Sebastien Deleuze
2016-12-23 17:58:34 +01:00
parent f51fe5fd39
commit fbf88d19da
17 changed files with 285 additions and 16 deletions

View File

@@ -50,7 +50,7 @@ import org.springframework.util.MimeTypeUtils;
public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Object> {
/**
* Server-Sent Events hint expecting a {@link Boolean} value which when set to true
* Server-Sent Events hint key expecting a {@link Boolean} value which when set to true
* will adapt the content in order to comply with Server-Sent Events recommendation.
* For example, it will append "data:" after each line break with data encoders
* supporting it.

View File

@@ -38,6 +38,11 @@ import org.springframework.util.MimeType;
*/
public class AbstractJackson2Codec {
/**
* Hint key to use with a {@link Class} value specifying the JSON View to use to serialize
* or deserialize an object.
* @see <a href="http://wiki.fasterxml.com/JacksonJsonViews">Jackson JSON Views</a>
*/
public static final String JSON_VIEW_HINT = AbstractJackson2Codec.class.getName() + ".jsonView";
protected static final List<MimeType> JSON_MIME_TYPES = Arrays.asList(