public static interface Body.Formatter
Modifier and Type | Method and Description |
---|---|
boolean |
canFormat(Class<?> type)
Test if the given type can be write it to the HTTP response body.
|
void |
format(Object body,
Body.Writer writer)
Attempt to write a message into the HTTP response body.
|
List<MediaType> |
types()
The
Accept header is tested against this type in order to decided if this
formatter accept or not a type. |
List<MediaType> types()
Accept
header is tested against this type in order to decided if this
formatter accept or not a type.boolean canFormat(@Nonnull Class<?> type)
type
- The candidate type.void format(@Nonnull Object body, @Nonnull Body.Writer writer) throws Exception
For text format (json, yaml, xml, etc.) a converter usually call to
Body.Writer.text(Body.Writer.Text)
in order to set charset and close resources.
For binary format a converter usually call to
Body.Writer.bytes(Body.Writer.Bytes)
in order to close resources.
body
- A body message.writer
- A write context.Exception
- If write operation fail.Copyright © 2015. All rights reserved.