22
33import java .util .List ;
44
5- import org .jooby .Body ;
6- import org .jooby .MediaType ;
7- import org .jooby .View ;
8-
95import com .google .common .collect .ImmutableList ;
106import com .google .common .io .CharStreams ;
117import com .google .inject .TypeLiteral ;
128
139public class BodyConverters {
1410
15- public static final Body . Parser fromJson = new Body . Parser () {
11+ public static final BodyParser fromJson = new BodyParser () {
1612
1713 @ Override
1814 public boolean canParse (final TypeLiteral <?> type ) {
1915 return true ;
2016 }
2117
2218 @ Override
23- public <T > T parse (final TypeLiteral <T > type , final Body . Reader reader ) throws Exception {
24- return reader .text (r -> CharStreams .toString (r ));
19+ public <T > T parse (final TypeLiteral <T > type , final BodyParser . Context ctx ) throws Exception {
20+ return ctx .text (r -> CharStreams .toString (r ));
2521 }
2622
2723 @ Override
@@ -31,15 +27,15 @@ public List<MediaType> types() {
3127
3228 };
3329
34- public static final Body . Formatter toJson = new Body . Formatter () {
30+ public static final BodyFormatter toJson = new BodyFormatter () {
3531
3632 @ Override
3733 public boolean canFormat (final Class <?> type ) {
3834 return true ;
3935 }
4036
4137 @ Override
42- public void format (final Object body , final Body . Writer writer )
38+ public void format (final Object body , final BodyFormatter . Context writer )
4339 throws Exception {
4440 writer .text (w -> w .write ("{\" body\" : \" " + body + "\" }" ));
4541 }
@@ -50,9 +46,9 @@ public List<MediaType> types() {
5046 }
5147 };
5248
53- public static final Body . Formatter toHtml = new View .Engine () {
49+ public static final BodyFormatter toHtml = new View .Engine () {
5450 @ Override
55- public void render (final View viewable , final Body . Writer writer ) throws Exception {
51+ public void render (final View viewable , final BodyFormatter . Context writer ) throws Exception {
5652 writer .text (w -> w .write ("<html><body>" + viewable + "</body></html>" ));
5753 }
5854 };
0 commit comments