|
|
|
@ -30,8 +30,6 @@ import java.util.ArrayList;
@@ -30,8 +30,6 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
|
|
import static dagger.Provides.Type.SET; |
|
|
|
|
import static feign.Logger.ErrorLogger; |
|
|
|
|
import static feign.Logger.Level.BASIC; |
|
|
|
|
|
|
|
|
|
public class WikipediaExample { |
|
|
|
|
|
|
|
|
@ -56,7 +54,8 @@ public class WikipediaExample {
@@ -56,7 +54,8 @@ public class WikipediaExample {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void main(String... args) throws InterruptedException { |
|
|
|
|
Wikipedia wikipedia = Feign.create(Wikipedia.class, "http://en.wikipedia.org", new WikipediaModule()); |
|
|
|
|
Wikipedia wikipedia = Feign.create(Wikipedia.class, "http://en.wikipedia.org", |
|
|
|
|
new WikipediaDecoder(), new LogToStderr()); |
|
|
|
|
|
|
|
|
|
System.out.println("Let's search for PTAL!"); |
|
|
|
|
Iterator<Page> pages = lazySearch(wikipedia, "PTAL"); |
|
|
|
@ -102,16 +101,8 @@ public class WikipediaExample {
@@ -102,16 +101,8 @@ public class WikipediaExample {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Module(overrides = true, library = true, includes = GsonModule.class) |
|
|
|
|
static class WikipediaModule { |
|
|
|
|
|
|
|
|
|
@Provides Logger.Level loggingLevel() { |
|
|
|
|
return BASIC; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Provides Logger logger() { |
|
|
|
|
return new ErrorLogger(); |
|
|
|
|
} |
|
|
|
|
@Module(library = true, includes = GsonModule.class) |
|
|
|
|
static class WikipediaDecoder { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* add to the set of Decoders one that handles {@code Response<Page>}. |
|
|
|
@ -142,4 +133,16 @@ public class WikipediaExample {
@@ -142,4 +133,16 @@ public class WikipediaExample {
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Module(overrides = true, library = true) |
|
|
|
|
static class LogToStderr { |
|
|
|
|
|
|
|
|
|
@Provides Logger.Level loggingLevel() { |
|
|
|
|
return Logger.Level.BASIC; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Provides Logger logger() { |
|
|
|
|
return new Logger.ErrorLogger(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|