{"id":21594176,"url":"https://github.com/justlive1/easy-http","last_synced_at":"2025-07-05T14:33:15.771Z","repository":{"id":37162807,"uuid":"195015842","full_name":"justlive1/easy-http","owner":"justlive1","description":"easy to contact http rest api","archived":false,"fork":false,"pushed_at":"2022-12-10T06:09:58.000Z","size":27,"stargazers_count":35,"open_issues_count":2,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-10T23:41:52.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justlive1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-03T08:51:22.000Z","updated_at":"2024-04-19T02:08:32.000Z","dependencies_parsed_at":"2023-01-25T22:10:11.823Z","dependency_job_id":null,"html_url":"https://github.com/justlive1/easy-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/justlive1/easy-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justlive1%2Feasy-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justlive1%2Feasy-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justlive1%2Feasy-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justlive1%2Feasy-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justlive1","download_url":"https://codeload.github.com/justlive1/easy-http/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justlive1%2Feasy-http/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263755664,"owners_count":23506431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T17:16:24.740Z","updated_at":"2025-07-05T14:33:15.720Z","avatar_url":"https://github.com/justlive1.png","language":"Java","funding_links":[],"categories":["HTTP客户端"],"sub_categories":["WebService框架"],"readme":"# easy-http\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/vip.justlive/easy-http/badge.svg)](https://maven-badges.herokuapp.com/maven-central/vip.justlive/easy-http/)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n\neasy to contact http rest api\n\n\n## 介绍\n\n- 基于Spring mvc`@RequestMapping`、`@GetMapping`、`@PostMapping`、`@RequestParam`、`RequestHeader`、`PathVariable`等注解扩展\n- 自动扫描接口实例化并托管至Spring，参考自Mybatis自动扫描Mapper\n- 需要声明的接口和Server端保持一致即可完美对接\n\n## 快速开始\n\n### 引入\n\n创建`Maven`项目\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003evip.justlive\u003c/groupId\u003e\n    \u003cartifactId\u003eeasy-http\u003c/artifactId\u003e\n    \u003cversion\u003e${lastVersion}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n或`Gradle`\n\n```\ncompile 'vip.justlive:easy-http:$lastVersion'\n```\n\n### 使用方式\n\n```java\n\n// 创建接口\n\n@HttpClient\n@RequestMapping(\"https://api.github.com\")\npublic interface GithubApi {\n\n  @RequestMapping(method = RequestMethod.GET)\n  String root();\n\n\n  @GetMapping(\"/repos/{owner}/{repo}\")\n  Repository repos(@PathVariable String owner, @PathVariable String repo);\n\n  @Data\n  class Repository {\n\n    private Long id;\n    private String name;\n    private int forks;\n    private int watchers;\n  }\n}\n\n// 使用${xx}获取配置\n@HttpClient\n@RequestMapping(\"${thirdpart.api.url}\")\npublic interface ThirdpartApi {\n\n  @PostMapping(\"/api/token\")\n  RespVo\u003cAccessToken\u003e token(@RequestParam String appKey, @RequestParam String appSecret);\n\n  @PostMapping(\"/api/account\")\n  RespVo\u003cAccount\u003e account(@RequestHeader String accessToken, @RequestBody Account account);\n\n  @Data\n  @Accessors(chain = true)\n  class AccessToken {\n\n    private String accessToken;\n    private Long expiresIn;\n  }\n\n  @Data\n  @Accessors(chain = true)\n  class Account {\n\n    private String name;\n    private BigDecimal balance;\n  }\n}\n\n// 增加扫描（默认为当前类所处包）\n\n@HttpClientScan(\"com.xxx\")\n@Configuration\npublic class HttpClientAutoConfiguration {\n\n}\n\n// 使用\n\n@Slf4j\n@Component\npublic class Demo {\n\n  @Autowired\n  private GithubApi githubApi;\n\n  @Autowired\n  private ThirdpartApi thirdpartApi;\n\n  @PostConstruct\n  private void init() {\n   \n    String result = githubApi.root();\n    log.info(\"githubApi root {}\", result);\n\n    Repository repository = githubApi.repos(\"justlive1\", \"easy-http\");\n    log.info(\"githubApi repos {}\", repository);\n    \n    AccessToken token = thirdpartApi.token(\"key\", \"secret\").getData();\n    log.info(\"thirdpartApi token {}\", token);\n\n    Account account = new Account().setName(\"aa\").setBalance(new BigDecimal(\"12.3\"));\n    account = thirdpartApi.account(token.getAccessToken(), account).getData();\n    log.info(\"thirdpartApi account {}\", account);\n  }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustlive1%2Feasy-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustlive1%2Feasy-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustlive1%2Feasy-http/lists"}