Skip to content

Commit f86da0c

Browse files
author
adriancole
committed
updated examples to 4.3 syntax
1 parent 41007cf commit f86da0c

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

example-github/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apply plugin: 'java'
22

33
dependencies {
4-
compile 'com.netflix.feign:feign-core:4.1.0'
5-
compile 'com.netflix.feign:feign-gson:4.1.0'
4+
compile 'com.netflix.feign:feign-core:4.3.0'
5+
compile 'com.netflix.feign:feign-gson:4.3.0'
66
provided 'com.squareup.dagger:dagger-compiler:1.1.0'
77
}
88

example-github/src/main/java/feign/example/github/GitHubExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static class Contributor {
4747
}
4848

4949
public static void main(String... args) throws InterruptedException {
50-
GitHub github = Feign.create(GitHub.class, "https://api.github.com", new GitHubModule());
50+
GitHub github = Feign.create(GitHub.class, "https://api.github.com", new GsonModule(), new LogToStderr());
5151

5252
System.out.println("Let's fetch and print a list of the contributors to this library.");
5353
List<Contributor> contributors = github.contributors("netflix", "feign");
@@ -95,8 +95,8 @@ public ContributorObserver(CountDownLatch latch) {
9595
}
9696
}
9797

98-
@Module(overrides = true, library = true, includes = GsonModule.class)
99-
static class GitHubModule {
98+
@Module(overrides = true, library = true)
99+
static class LogToStderr {
100100

101101
@Provides Logger.Level loggingLevel() {
102102
return Logger.Level.BASIC;

example-wikipedia/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apply plugin: 'java'
22

33
dependencies {
4-
compile 'com.netflix.feign:feign-core:4.1.0'
5-
compile 'com.netflix.feign:feign-gson:4.1.0'
4+
compile 'com.netflix.feign:feign-core:4.3.0'
5+
compile 'com.netflix.feign:feign-gson:4.3.0'
66
provided 'com.squareup.dagger:dagger-compiler:1.1.0'
77
}
88

example-wikipedia/src/main/java/feign/example/wikipedia/WikipediaExample.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
import java.util.Iterator;
3131

3232
import static dagger.Provides.Type.SET;
33-
import static feign.Logger.ErrorLogger;
34-
import static feign.Logger.Level.BASIC;
3533

3634
public class WikipediaExample {
3735

@@ -56,7 +54,8 @@ public static class Response<X> extends ArrayList<X> {
5654
}
5755

5856
public static void main(String... args) throws InterruptedException {
59-
Wikipedia wikipedia = Feign.create(Wikipedia.class, "http://en.wikipedia.org", new WikipediaModule());
57+
Wikipedia wikipedia = Feign.create(Wikipedia.class, "http://en.wikipedia.org",
58+
new WikipediaDecoder(), new LogToStderr());
6059

6160
System.out.println("Let's search for PTAL!");
6261
Iterator<Page> pages = lazySearch(wikipedia, "PTAL");
@@ -102,16 +101,8 @@ public void remove() {
102101
};
103102
}
104103

105-
@Module(overrides = true, library = true, includes = GsonModule.class)
106-
static class WikipediaModule {
107-
108-
@Provides Logger.Level loggingLevel() {
109-
return BASIC;
110-
}
111-
112-
@Provides Logger logger() {
113-
return new ErrorLogger();
114-
}
104+
@Module(library = true, includes = GsonModule.class)
105+
static class WikipediaDecoder {
115106

116107
/**
117108
* add to the set of Decoders one that handles {@code Response<Page>}.
@@ -142,4 +133,16 @@ protected Page build(JsonReader reader) throws IOException {
142133
};
143134
}
144135
}
136+
137+
@Module(overrides = true, library = true)
138+
static class LogToStderr {
139+
140+
@Provides Logger.Level loggingLevel() {
141+
return Logger.Level.BASIC;
142+
}
143+
144+
@Provides Logger logger() {
145+
return new Logger.ErrorLogger();
146+
}
147+
}
145148
}

0 commit comments

Comments
 (0)