@@ -103,22 +103,12 @@ and returns a single result of the given type.
103103}
104104----
105105
106- <1> Choose your favorite `jackson ` library
106+ <1> Choose your favorite `json ` library
107107<2> Check if the `Content-Type` header matches `application/json`
108108<3> Read the body as `byte[]`
109109<4> Parse the `body` and use the requested type
110110<5> Route handler now call the `body(Type)` function to trigger the decoder function
111111
112- [TIP]
113- ====
114-
115- Jooby comes with a `jackson` decoder built on top of https://github.com/FasterXML/jackson-databind[Jackson]:
116-
117- [dependency, artifactId="jooby-jackson"]
118- .
119-
120- ====
121-
122112=== Response Body
123113
124114Response body is generated from `handler` function:
@@ -162,19 +152,22 @@ Response body is generated from `handler` function:
162152
163153==== Message Encoder
164154
165- Response enconding is achieved using the javadoc:MessageEncoder[] functional interface.
155+ Response encoding is achieved using the javadoc:MessageEncoder[] functional interface.
166156
167157[source, java]
168158----
169159public interface MessageEncoder {
170160
171- byte[] encode(@NonNull Context ctx, @NonNull Object value) throws Exception;
161+ DataBuffer encode(@NonNull Context ctx, @NonNull Object value) throws Exception;
172162}
173163----
174164
175- MessageEncoder has a single `encode` method that accepts two input arguments: `(context, result )` and
165+ MessageEncoder has a single `encode` method that accepts two input arguments: `(context, value )` and
176166produces a result.
177167
168+ The javadoc:buffer.DataBuffer[buffer] works like `java.nio.ByteBuffer` and it is used internally
169+ for performance reason.
170+
178171.JSON example:
179172[source, java, role="primary"]
180173----
@@ -219,19 +212,9 @@ produces a result.
219212}
220213----
221214
222- <1> Choose your favorite `jackson ` library
215+ <1> Choose your favorite `json ` library
223216<2> Check if the `Accept` header matches `application/json`
224217<3> Convert `result` to `JSON`
225218<4> Set default `Content-Type` to `application/json`
226219<5> Produces JSON response
227220<6> Route handler returns a user defined type
228-
229- [TIP]
230- ====
231-
232- Jooby comes with a `jackson` encoder built on top of https://github.com/FasterXML/jackson-databind[Jackson]:
233-
234- [dependency, artifactId="jooby-jackson"]
235- .
236-
237- ====
0 commit comments