@ -35,8 +37,6 @@ public static void main(String... args) {
@@ -35,8 +37,6 @@ public static void main(String... args) {
}
```
Feign includes a fully functional json codec in the `feign-gson` extension. See the `Decoder` section for how to write your own.
### Customization
Feign has several aspects that can be customized. For simple cases, you can use `Feign.builder()` to construct an API interface with your custom components. For example:
@ -83,9 +83,14 @@ Feign intends to work well within Netflix and other Open Source communities. Mo
@@ -83,9 +83,14 @@ Feign intends to work well within Netflix and other Open Source communities. Mo
### Gson
[GsonModule](https://github.com/Netflix/feign/tree/master/gson) adds default encoders and decoders so you get get started with a JSON api.
Integration requires you pass `new GsonModule()` to `Feign.create()`, or add it to your graph with Dagger:
Add `GsonCodec` to your `Feign.Builder` like so:
```java
GitHub github = Feign.create(GitHub.class, "https://api.github.com", new GsonModule());
GsonCodec codec = new GsonCodec();
GitHub github = Feign.builder()
.encoder(codec)
.decoder(codec)
.target(GitHub.class, "https://api.github.com");
```
### Sax
@ -119,26 +124,16 @@ MyService api = Feign.create(MyService.class, "https://myAppProd", new RibbonMod
@@ -119,26 +124,16 @@ MyService api = Feign.create(MyService.class, "https://myAppProd", new RibbonMod
```
### Decoders
The last argument to `Feign.create` allows you to specify additional configuration such as how to decode a responses, modeled in Dagger.
`Feign.builder()` allows you to specify additional configuration such as how to decode a response.
If any methods in your interface return types besides `Response` or `void`, you'll need to configure a `Decoder`.
The `GsonModule` in the `feign-gson` extension configures a `Decoder` which parses objects from JSON using reflection.
Here's how to configure json decoding (using the `feign-gson` extension):
Here's how you could write this yourself, using whatever library you prefer:
@ -166,15 +161,9 @@ Where possible, Feign configuration uses normal Dagger conventions. For example
@@ -166,15 +161,9 @@ Where possible, Feign configuration uses normal Dagger conventions. For example
#### Logging
You can log the http messages going to and from the target by setting up a `Logger`. Here's the easiest way to do that: