Feig使得JavaHTTP客户端编写更方便。
Feig灵感来源于Retrofit,JAXRS-2.0和WebSocket,Feig最初是为了降低统一绑定Deomiator到HTTPAPIs的复杂度,不管是否是Restful。
Feig使用Jersey和CXF之类的工具为ReST或SOAP服务编写Java客户端。此外,Feig允许用户在诸如ApacheHC之类的http库之上编写自己的代码。Feig通过可定制的解码器和错误处理功能,以最小的开销和代码将代码连接到httpAPI,这些错误和错误处理可以写入任何基于文本的httpAPI。
基础使用:
iterface GitHub { @RequestLie("GET /repos/{ower}/{repo}/cotributors") List<Cotributor> cotributors(@Param("ower") Strig ower, @Param("repo") Strig repo);}static class Cotributor { Strig logi; it cotributios;}public static void mai(Strig... args) { GitHub github = Feig.builder() .decoder(ew GsoDecoder()) .target(GitHub.class, "https://api.github.com"); // Fetch ad prit a list of the cotributors to this library. List<Cotributor> cotributors = github.cotributors("etflix", "feig"); for (Cotributor cotributor : cotributors) { System.out.pritl(cotributor.logi + " (" + cotributor.cotributios + ")"); }}









评论