1515 */
1616package feign .example .github ;
1717
18- import dagger .Module ;
19- import dagger .Provides ;
2018import feign .Feign ;
2119import feign .Logger ;
20+ import feign .Param ;
2221import feign .RequestLine ;
23- import feign .gson .GsonModule ;
22+ import feign .gson .GsonDecoder ;
2423import java .util .List ;
25- import javax .inject .Named ;
2624
2725/** adapted from {@code com.example.retrofit.GitHubClient} */
2826public class GitHubExample {
2927
3028 interface GitHub {
3129 @ RequestLine ("GET /repos/{owner}/{repo}/contributors" )
32- List <Contributor > contributors (@ Named ("owner" ) String owner , @ Named ("repo" ) String repo );
30+ List <Contributor > contributors (@ Param ("owner" ) String owner , @ Param ("repo" ) String repo );
3331 }
3432
3533 static class Contributor {
@@ -39,26 +37,16 @@ static class Contributor {
3937
4038 public static void main (String ... args ) throws InterruptedException {
4139 GitHub github =
42- Feign .create (GitHub .class , "https://api.github.com" , new GsonModule (), new LogToStderr ());
40+ Feign .builder ()
41+ .decoder (new GsonDecoder ())
42+ .logger (new Logger .ErrorLogger ())
43+ .logLevel (Logger .Level .BASIC )
44+ .target (GitHub .class , "https://api.github.com" );
4345
4446 System .out .println ("Let's fetch and print a list of the contributors to this library." );
4547 List <Contributor > contributors = github .contributors ("netflix" , "feign" );
4648 for (Contributor contributor : contributors ) {
4749 System .out .println (contributor .login + " (" + contributor .contributions + ")" );
4850 }
4951 }
50-
51- @ Module (overrides = true , library = true , includes = GsonModule .class )
52- static class LogToStderr {
53-
54- @ Provides
55- Logger .Level loggingLevel () {
56- return Logger .Level .BASIC ;
57- }
58-
59- @ Provides
60- Logger logger () {
61- return new Logger .ErrorLogger ();
62- }
63- }
6452}
0 commit comments