public static interface View.Engine extends Body.Formatter
View
.Modifier and Type | Method and Description |
---|---|
default boolean |
canFormat(Class<?> type)
Test if the given type can be write it to the HTTP response body.
|
default void |
format(Object body,
Body.Writer writer)
Attempt to write a message into the HTTP response body.
|
default String |
name() |
void |
render(View viewable,
Body.Writer writer)
Render a view.
|
default List<MediaType> |
types()
The
Accept header is tested against this type in order to decided if this
formatter accept or not a type. |
default String name()
default List<MediaType> types()
Body.Formatter
Accept
header is tested against this type in order to decided if this
formatter accept or not a type.types
in interface Body.Formatter
default boolean canFormat(Class<?> type)
Body.Formatter
canFormat
in interface Body.Formatter
type
- The candidate type.default void format(Object body, Body.Writer writer) throws Exception
Body.Formatter
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.
format
in interface Body.Formatter
body
- A body message.writer
- A write context.Exception
- If write operation fail.void render(View viewable, Body.Writer writer) throws Exception
viewable
- View to render.writer
- A body writer.Exception
- If view rendering fails.Copyright © 2014. All rights reserved.