Compare commits

...

3 Commits
master ... 2.x

Author SHA1 Message Date
adriancole d4832cfbba fix duplicate binding error using jaxrs 11 years ago
adriancole 897318177a update example to use feign 2.0.0 syntax 12 years ago
adriancole 9a24c59b07 version 2.0.1-SNAPSHOT 12 years ago
  1. 2
      examples/feign-example-cli/build.gradle
  2. 21
      examples/feign-example-cli/src/main/java/feign/example/cli/GitHubExample.java
  3. 2
      feign-jaxrs/src/main/java/feign/jaxrs/JAXRSModule.java
  4. 2
      gradle.properties

2
examples/feign-example-cli/build.gradle

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
apply plugin: 'java'
dependencies {
compile 'com.netflix.feign:feign-core:1.1.1'
compile 'com.netflix.feign:feign-core:2.0.0'
compile 'com.google.code.gson:gson:2.2.4'
provided 'com.squareup.dagger:dagger-compiler:1.0.1'
}

21
examples/feign-example-cli/src/main/java/feign/example/cli/GitHubExample.java

@ -15,22 +15,21 @@ @@ -15,22 +15,21 @@
*/
package feign.example.cli;
import com.google.common.collect.ImmutableMap;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import java.io.Reader;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import dagger.Module;
import dagger.Provides;
import feign.Feign;
import feign.RequestLine;
import feign.codec.Decoder;
/**
@ -39,8 +38,8 @@ import feign.codec.Decoder; @@ -39,8 +38,8 @@ import feign.codec.Decoder;
public class GitHubExample {
interface GitHub {
@GET @Path("/repos/{owner}/{repo}/contributors")
List<Contributor> contributors(@PathParam("owner") String owner, @PathParam("repo") String repo);
@RequestLine("GET /repos/{owner}/{repo}/contributors")
List<Contributor> contributors(@Named("owner") String owner, @Named("repo") String repo);
}
static class Contributor {
@ -64,14 +63,16 @@ public class GitHubExample { @@ -64,14 +63,16 @@ public class GitHubExample {
@Module(overrides = true, library = true)
static class GsonModule {
@Provides @Singleton Map<String, Decoder> decoders() {
return ImmutableMap.of("GitHub", jsonDecoder);
Map<String, Decoder> decoders = new LinkedHashMap<String, Decoder>();
decoders.put("GitHub", jsonDecoder);
return decoders;
}
final Decoder jsonDecoder = new Decoder() {
Gson gson = new Gson();
@Override public Object decode(String methodKey, Reader reader, TypeToken<?> type) {
return gson.fromJson(reader, type.getType());
@Override public Object decode(String methodKey, Reader reader, Type type) {
return gson.fromJson(reader, type);
}
};
}

2
feign-jaxrs/src/main/java/feign/jaxrs/JAXRSModule.java

@ -38,7 +38,7 @@ import static feign.Util.CONTENT_TYPE; @@ -38,7 +38,7 @@ import static feign.Util.CONTENT_TYPE;
import static feign.Util.checkState;
import static feign.Util.join;
@dagger.Module(library = true)
@dagger.Module(library = true, overrides = true)
public final class JAXRSModule {
@Provides Contract provideContract() {

2
gradle.properties

@ -1 +1 @@ @@ -1 +1 @@
version=2.0.0-SNAPSHOT
version=2.0.1-SNAPSHOT

Loading…
Cancel
Save