接口 HttpMessageWriter<T>

类型参数:
T - the type of objects in the input stream
所有已知实现类:
EncoderHttpMessageWriter, FormHttpMessageWriter, MultipartHttpMessageWriter, PartEventHttpMessageWriter, PartHttpMessageWriter, ProtobufHttpMessageWriter, ResourceHttpMessageWriter, ServerSentEventHttpMessageWriter

public interface HttpMessageWriter<T>
Strategy for encoding a stream of objects of type <T> and writing the encoded stream of bytes to an ReactiveHttpOutputMessage.
从以下版本开始:
4.0
作者:
Rossen Stoyanchev, Arjen Poutsma, Sebastien Deleuze
  • 方法详细资料

    • getWritableMediaTypes

      List<MediaType> getWritableMediaTypes()
      Return the list of media types supported by this Writer. The list may not apply to every possible target element type and calls to this method should typically be guarded via canWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, use getWritableMediaTypes(ResolvableType) for a more precise list.
      返回:
      the general list of supported media types
    • getWritableMediaTypes

      default List<MediaType> getWritableMediaTypes(cn.taketoday.core.ResolvableType elementType)
      Return the list of media types supported by this Writer for the given type of element. This list may differ from getWritableMediaTypes() if the Writer doesn't support the element type, or if it supports it only for a subset of media types.
      参数:
      elementType - the type of element to encode
      返回:
      the list of media types supported for the given class
    • canWrite

      boolean canWrite(cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType)
      Whether the given object type is supported by this writer.
      参数:
      elementType - the type of object to check
      mediaType - the media type for the write (possibly null)
      返回:
      true if writable, false otherwise
    • write

      reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
      Write an given stream of object to the output message.
      参数:
      inputStream - the objects to write
      elementType - the type of objects in the stream which must have been previously checked via canWrite(ResolvableType, MediaType)
      mediaType - the content type for the write (possibly null to indicate that the default content type of the writer must be used)
      message - the message to write to
      hints - additional information about how to encode and write
      返回:
      indicates completion or error
    • write

      default reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends T> inputStream, cn.taketoday.core.ResolvableType actualType, cn.taketoday.core.ResolvableType elementType, @Nullable MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
      Server-side only alternative to write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map) with additional context available.
      参数:
      actualType - the actual return type of the method that returned the value; for annotated controllers, the Parameter can be accessed via ResolvableType.getSource().
      elementType - the type of Objects in the input stream
      mediaType - the content type to use (possibly null indicating the default content type of the writer should be used)
      request - the current request
      response - the current response
      返回:
      a Mono that indicates completion of writing or error