15
15
*/
16
16
package feign .example .github ;
17
17
18
- import dagger .Module ;
19
- import dagger .Provides ;
20
18
import feign .Feign ;
21
19
import feign .Logger ;
20
+ import feign .Param ;
22
21
import feign .RequestLine ;
23
- import feign .gson .GsonModule ;
22
+ import feign .gson .GsonDecoder ;
24
23
import java .util .List ;
25
- import javax .inject .Named ;
26
24
27
25
/** adapted from {@code com.example.retrofit.GitHubClient} */
28
26
public class GitHubExample {
29
27
30
28
interface GitHub {
31
29
@ 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 );
33
31
}
34
32
35
33
static class Contributor {
@@ -39,26 +37,16 @@ static class Contributor {
39
37
40
38
public static void main (String ... args ) throws InterruptedException {
41
39
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" );
43
45
44
46
System .out .println ("Let's fetch and print a list of the contributors to this library." );
45
47
List <Contributor > contributors = github .contributors ("netflix" , "feign" );
46
48
for (Contributor contributor : contributors ) {
47
49
System .out .println (contributor .login + " (" + contributor .contributions + ")" );
48
50
}
49
51
}
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
- }
64
52
}
0 commit comments