【文件属性】:
文件名称:JavaHTTP客户端库Feign.zip
文件大小:487KB
文件格式:ZIP
更新时间:2022-08-05 02:31:27
开源项目
Feign 使得 Java HTTP 客户端编写更方便。Feign 灵感来源于 Retrofit, JAXRS-2.0 和 WebSocket,Feign 最初是为了降低统一绑定 Denominator 到 HTTP APIs 的复杂度,不管是否是 Restful 。基础使用:interface GitHub {
@RequestLine("GET /repos/{owner}/{repo}/contributors")
List contributors(@Param("owner") String owner, @Param("repo") String repo);
}
static class Contributor {
String login;
int contributions;
}
public static void main(String... args) {
GitHub github = Feign.builder()
.decoder(new GsonDecoder())
.target(GitHub.class, "https://api.github.com");
// Fetch and print a list of the contributors to this library.
List contributors = github.contributors("netflix", "feign");
for (Contributor contributor : contributors) {
System.out.println(contributor.login " (" contributor.contributions ")");
}
}
标签:Feign