Interface HttpMessageEncoder<T>

Type Parameters:
T - the type of elements in the input stream
All Superinterfaces:
org.springframework.core.codec.Encoder<T>
All Known Implementing Classes:
AbstractJackson2Encoder, Jackson2CborEncoder, Jackson2JsonEncoder, Jackson2SmileEncoder, ProtobufEncoder

public interface HttpMessageEncoder<T> extends org.springframework.core.codec.Encoder<T>
Extension of Encoder exposing extra methods relevant in the context of HTTP request or response body encoding.
Since:
5.0
Author:
Rossen Stoyanchev
  • Method Summary

    Modifier and Type
    Method
    Description
    default Map<String,Object>
    getEncodeHints(org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
    Get decoding hints based on the server request or annotations on the target controller method parameter.
    Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.

    Methods inherited from interface org.springframework.core.codec.Encoder

    canEncode, encode, encodeValue, getEncodableMimeTypes, getEncodableMimeTypes
  • Method Details

    • getStreamingMediaTypes

      List<MediaType> getStreamingMediaTypes()
      Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.
    • getEncodeHints

      default Map<String,Object> getEncodeHints(org.springframework.core.ResolvableType actualType, org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
      Get decoding hints based on the server request or annotations on the target controller method parameter.
      Parameters:
      actualType - the actual source type to encode, possibly a reactive wrapper and sourced from MethodParameter, i.e. providing access to method annotations.
      elementType - the element type within Flux/Mono that we're trying to encode.
      request - the current request
      response - the current response
      Returns:
      a Map with hints, possibly empty