Skip to content

Commit f6776e9

Browse files
committed
MessageEncoder docs are outdated fix #3726
1 parent 8224f9c commit f6776e9

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

docs/asciidoc/body.adoc

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

124114
Response 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
----
169159
public 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
176166
produces 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-
====

jooby/src/main/java/io/jooby/MessageEncoder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ public interface MessageEncoder {
3030
};
3131

3232
/**
33-
* MessageEncoder a value into a byte array or <code>null</code> if given object isn't supported
34-
* it.
33+
* Encodes a value into a buffer or <code>null</code> if a given object isn't supported it.
3534
*
3635
* @param ctx Web context.
3736
* @param value Value to render.
38-
* @return Value as byte array or <code>null</code> if given object isn't supported it.
37+
* @return Encoded value or <code>null</code> if given object isn't supported it.
3938
* @throws Exception If something goes wrong.
4039
*/
4140
@Nullable DataBuffer encode(@NonNull Context ctx, @NonNull Object value) throws Exception;

0 commit comments

Comments
 (0)