Skip to content

Commit eb03e20

Browse files
author
adriancole
committed
updated docs on decoder
1 parent 1d30392 commit eb03e20

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ MyService api = Feign.create(MyService.class, "https://myAppProd", new RibbonMod
121121
### Decoders
122122
The last argument to `Feign.create` allows you to specify additional configuration such as how to decode a responses, modeled in Dagger.
123123

124-
If any methods in your interface return types besides `Response`, `void` or `String`, you'll need to configure a `Decoder`.
124+
If any methods in your interface return types besides `Response` or `void`, you'll need to configure a `Decoder`.
125125

126126
The `GsonModule` in the `feign-gson` extension configures a `Decoder` which parses objects from JSON using reflection.
127127

core/src/main/java/feign/codec/Decoder.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import static java.lang.String.format;
2626

2727
/**
28-
* Decodes an HTTP response into a single object of the given {@code Type}. Invoked when
28+
* Decodes an HTTP response into a single object of the given {@code type}. Invoked when
2929
* {@link Response#status()} is in the 2xx range and the return type is neither {@code void} nor {@code Response}.
3030
* <p/>
3131
* <p/>
@@ -49,14 +49,25 @@
4949
* }
5050
* }
5151
* </pre>
52+
* <br/>
53+
* <h3>Implementation Note</h3>
54+
* The {@code type} parameter will correspond to the
55+
* {@link java.lang.reflect.Method#getGenericReturnType() generic return type}
56+
* of an {@link feign.Target#type() interface} processed by
57+
* {@link feign.Feign#newInstance(feign.Target)}. When writing your
58+
* implementation of Decoder, ensure you also test parameterized types such as
59+
* {@code List<Foo>}.
60+
*
5261
*/
5362
public interface Decoder {
5463
/**
55-
* Decodes a response into a single object.
64+
* Decodes an http response into an object corresponding to its
65+
* {@link java.lang.reflect.Method#getGenericReturnType() generic return type}.
5666
* If you need to wrap exceptions, please do so via {@link DecodeException}.
5767
*
5868
* @param response the response to decode
59-
* @param type Target object type.
69+
* @param type {@link java.lang.reflect.Method#getGenericReturnType() generic return type}
70+
* of the method corresponding to this {@code response}.
6071
* @return instance of {@code type}
6172
* @throws IOException will be propagated safely to the caller.
6273
* @throws DecodeException when decoding failed due to a checked exception besides IOException.

0 commit comments

Comments
 (0)