Package io.micronaut.http.body
Interface ResponseBodyWriter<T>
- Type Parameters:
T- The body type
- All Superinterfaces:
MessageBodyWriter<T>
- All Known Implementing Classes:
FileBodyWriter,InputStreamBodyWriter,NettyCharSequenceBodyWriter,NettyJsonHandler,NettyWritableBodyWriter,ResponseBodyWriterWrapper,StreamFileBodyWriter,SystemFileBodyWriter
@Indexed(MessageBodyWriter.class)
public interface ResponseBodyWriter<T>
extends MessageBodyWriter<T>
Extension to
MessageBodyWriter that is specific to writing the server response body. This
allows more fine-grained control over the response than the MessageBodyWriter API.- Since:
- 4.7.0
- Author:
- Jonas Konrad
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull ResponseBodyWriter<T>wrap(@NonNull MessageBodyWriter<T> writer) Wrap the given writer, if necessary, to get aResponseBodyWriter.write(@NonNull ByteBufferFactory<?, ?> bufferFactory, @NonNull HttpRequest<?> request, @NonNull MutableHttpResponse<T> httpResponse, @NonNull Argument<T> type, @NonNull MediaType mediaType, T object) Writes an object as aByteBodyHttpResponse.Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable, writeTo, writeTo
-
Method Details
-
write
@NonNull @NonNull ByteBodyHttpResponse<?> write(@NonNull @NonNull ByteBufferFactory<?, ?> bufferFactory, @NonNull @NonNull HttpRequest<?> request, @NonNull @NonNull MutableHttpResponse<T> httpResponse, @NonNull @NonNull Argument<T> type, @NonNull @NonNull MediaType mediaType, T object) throws CodecExceptionWrites an object as aByteBodyHttpResponse.- Parameters:
bufferFactory- The buffer factoryrequest- The requesthttpResponse- The responsetype- The response body typemediaType- The media typeobject- The object to write- Returns:
- A
ByteBodyHttpResponsewith the response bytes - Throws:
CodecException- If an error occurs encoding
-
wrap
@NonNull static <T> @NonNull ResponseBodyWriter<T> wrap(@NonNull @NonNull MessageBodyWriter<T> writer) Wrap the given writer, if necessary, to get aResponseBodyWriter.- Type Parameters:
T- The body type- Parameters:
writer- The generic message writer- Returns:
- The response writer
-