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 ;
24-
25- import javax .inject .Named ;
22+ import feign .gson .GsonDecoder ;
2623import java .util .List ;
2724
2825/**
@@ -32,7 +29,7 @@ public class GitHubExample {
3229
3330 interface GitHub {
3431 @ RequestLine ("GET /repos/{owner}/{repo}/contributors" )
35- List <Contributor > contributors (@ Named ("owner" ) String owner , @ Named ("repo" ) String repo );
32+ List <Contributor > contributors (@ Param ("owner" ) String owner , @ Param ("repo" ) String repo );
3633 }
3734
3835 static class Contributor {
@@ -41,24 +38,16 @@ static class Contributor {
4138 }
4239
4340 public static void main (String ... args ) throws InterruptedException {
44- GitHub github = Feign .create (GitHub .class , "https://api.github.com" , new GsonModule (), new LogToStderr ());
41+ GitHub github = Feign .builder ()
42+ .decoder (new GsonDecoder ())
43+ .logger (new Logger .ErrorLogger ())
44+ .logLevel (Logger .Level .BASIC )
45+ .target (GitHub .class , "https://api.github.com" );
4546
4647 System .out .println ("Let's fetch and print a list of the contributors to this library." );
4748 List <Contributor > contributors = github .contributors ("netflix" , "feign" );
4849 for (Contributor contributor : contributors ) {
4950 System .out .println (contributor .login + " (" + contributor .contributions + ")" );
5051 }
5152 }
52-
53- @ Module (overrides = true , library = true , includes = GsonModule .class )
54- static class LogToStderr {
55-
56- @ Provides Logger .Level loggingLevel () {
57- return Logger .Level .BASIC ;
58- }
59-
60- @ Provides Logger logger () {
61- return new Logger .ErrorLogger ();
62- }
63- }
6453}
0 commit comments