{"id":15479191,"url":"https://github.com/adwpc/xhttp","last_synced_at":"2026-02-14T06:31:43.337Z","repository":{"id":144203949,"uuid":"179252017","full_name":"adwpc/xhttp","owner":"adwpc","description":"golang powerful http client, easy to use","archived":false,"fork":false,"pushed_at":"2025-03-11T07:37:42.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T02:38:15.163Z","etag":null,"topics":["chain-expression","golang","header-customization","http-client","parse-json","timeout"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adwpc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-04-03T09:04:41.000Z","updated_at":"2025-03-11T07:37:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa27c2af-a873-41d7-992f-8fec2422a92a","html_url":"https://github.com/adwpc/xhttp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/adwpc/xhttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adwpc%2Fxhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adwpc%2Fxhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adwpc%2Fxhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adwpc%2Fxhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adwpc","download_url":"https://codeload.github.com/adwpc/xhttp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adwpc%2Fxhttp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29438765,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T05:24:35.651Z","status":"ssl_error","status_checked_at":"2026-02-14T05:24:34.830Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["chain-expression","golang","header-customization","http-client","parse-json","timeout"],"created_at":"2024-10-02T04:20:19.716Z","updated_at":"2026-02-14T06:31:43.323Z","avatar_url":"https://github.com/adwpc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XHttp\n\nXHttp is a http client written by golang\n\n[![GoDoc](https://godoc.org/github.com/adwpc/xhttp?status.svg)](https://godoc.org/github.com/adwpc/xhttp)\n[![Build Status](https://travis-ci.org/adwpc/xhttp.svg?branch=master)](https://travis-ci.org/adwpc/xhttp)\n\nfeature|特性\n---|---\neasy to use|使用简单\nchain expression|链式表达式\nset your request method/header/param/body|支持请求方法/头/参数/体\nget json/string/json's key from response|支持获取json/string/json字段\ncustom timeout|支持自定义超时\nno \"defer resp.Body.Close()\"|免\"defer resp.Body.Close()\"\n\n# Usage\n\n```\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/adwpc/xhttp\"\n\t\"github.com/buger/jsonparser\"\n)\n\ntype Json struct {\n\tArgs    map[string]string\n\tHeaders map[string]string\n\tOrigin  string\n\tUrl     string\n}\n\nfunc simpleGetRespToString() {\n\tfmt.Println(\"--------simpleGetRespToString-----------\")\n\tip, err := xhttp.New().Get().RespToString(\"http://httpbin.org/get\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(ip)\n\tv, _, _, _ := jsonparser.Get([]byte(ip), \"headers\", \"Host\")\n\tfmt.Println(string(v))\n}\n\nfunc simpleGetRespJsonKey() {\n\tfmt.Println(\"--------simpleGetRespJsonKey-----------\")\n\thost, err := xhttp.New().Get().RespGetJsonKey(\"http://httpbin.org/get\", \"origin\")\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(string(host))\n}\n\nfunc customGetRespToJson() {\n\tfmt.Println(\"--------customGetRespToJson-----------\")\n\tvar j Json\n\terr := xhttp.NewWithTimeout(5000, 5000, 10000).Get().AddHeader(\"a\", \"b\").AddParam(\"c\", \"d\").SetBody(\"{\\\"e\\\":\\\"f\\\"}\").RespToJson(\"http://httpbin.org/get\", \u0026j)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(j)\n}\n\nfunc multiCustomPostRespToJson() {\n\tfmt.Println(\"--------multiCustomPostRespToJson-----------\")\n\theaders := make(map[string]string)\n\theaders[\"a\"] = \"b\"\n\theaders[\"c\"] = \"d\"\n\n\tparams := make(map[string]string)\n\tparams[\"q\"] = \"ip\"\n\n\tvar j Json\n\terr := xhttp.New().Post().AddHeaders(headers).AddParams(params).SetBody(\"{\\\"e\\\":\\\"f\\\"}\").RespToJson(\"http://httpbin.org/post\", \u0026j)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(j)\n}\nfunc main() {\n\tsimpleGetRespToString()\n\tsimpleGetRespJsonKey()\n\tcustomGetRespToJson()\n\tmultiCustomPostRespToJson()\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwpc%2Fxhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadwpc%2Fxhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadwpc%2Fxhttp/lists"}