{"id":19169074,"url":"https://github.com/dreamph/reqx","last_synced_at":"2025-05-07T14:43:37.205Z","repository":{"id":192611373,"uuid":"391588722","full_name":"dreamph/reqx","owner":"dreamph","description":"High Performance HTTP client for Go","archived":false,"fork":false,"pushed_at":"2024-12-29T04:26:08.000Z","size":31,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T23:32:02.429Z","etag":null,"topics":["client","go-http-client","golang","http-client","http-request","http-requests","httpclient","req","rest-client"],"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/dreamph.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":"2021-08-01T09:54:21.000Z","updated_at":"2024-12-29T04:26:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"f5529e07-3724-4f97-be8e-ac9b22c0e7c9","html_url":"https://github.com/dreamph/reqx","commit_stats":null,"previous_names":["dreamph/reqx"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Freqx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Freqx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Freqx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreamph%2Freqx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreamph","download_url":"https://codeload.github.com/dreamph/reqx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252897746,"owners_count":21821502,"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":["client","go-http-client","golang","http-client","http-request","http-requests","httpclient","req","rest-client"],"created_at":"2024-11-09T09:44:53.005Z","updated_at":"2025-05-07T14:43:37.187Z","avatar_url":"https://github.com/dreamph.png","language":"Go","readme":"# reqx\n\nGolang http client\n- Light weight\n- Simple \u0026 Easy \n\n\nInstall\n=======\n``` sh\ngo get github.com/dreamph/reqx\n```\n\n\nBenchmark (reqx vs go http)\n=======\n``` sh\ngo test -bench . -benchmem -count 1\n\nBenchmark_ReqxRequests/GET-12                      47740             22771 ns/op            1768 B/op         25 allocs/op\nBenchmark_ReqxRequests/POST-12                     47290             24967 ns/op            1995 B/op         33 allocs/op\nBenchmark_ReqxRequests/PUT-12                      47718             24997 ns/op            1991 B/op         33 allocs/op\nBenchmark_ReqxRequests/PATCH-12                    47674             24923 ns/op            1992 B/op         33 allocs/op\nBenchmark_ReqxRequests/DELETE-12                   47343             24903 ns/op            2004 B/op         33 allocs/op\nBenchmark_GoHttpRequests/GET-12                    36661             31616 ns/op            5792 B/op         69 allocs/op\nBenchmark_GoHttpRequests/POST-12                   34401             34127 ns/op            7456 B/op         88 allocs/op\nBenchmark_GoHttpRequests/PUT-12                    34412             34492 ns/op            7389 B/op         88 allocs/op\nBenchmark_GoHttpRequests/PATCH-12                  34220             34656 ns/op            7494 B/op         88 allocs/op\nBenchmark_GoHttpRequests/DELETE-12                 34275             34700 ns/op            7473 B/op         88 allocs/op\n\n```\n\nExamples\n=======\n``` go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"github.com/dreamph/reqx\"\n\t\"log\"\n\t\"os\"\n\t\"time\"\n)\n\ntype Data struct {\n\tName string `json:\"name,omitempty\"`\n}\n\ntype Response struct {\n\tOrigin string `json:\"origin\"`\n}\n\nfunc main() {\n\tclientWithBaseURL := reqx.New(\n\t\treqx.WithBaseURL(\"https://httpbin.org\"),\n\t\treqx.WithTimeout(10*time.Second),\n\t\treqx.WithHeaders(reqx.Headers{\n\t\t\treqx.HeaderAuthorization: \"Bearer 123456\",\n\t\t}),\n\t\treqx.WithOnBeforeRequest(func(req *reqx.RequestInfo) {\n\t\t\tfmt.Println(req.String())\n\t\t}),\n\t\treqx.WithOnRequestCompleted(func(req *reqx.RequestInfo, resp *reqx.ResponseInfo) {\n\t\t\tfmt.Println(resp.String())\n\t\t}),\n\t\treqx.WithOnRequestError(func(req *reqx.RequestInfo, resp *reqx.ResponseInfo) {\n\t\t\tfmt.Println(resp.String())\n\t\t}),\n\t)\n\n\t//POST\n\tresult := \u0026Response{}\n\tresp, err := clientWithBaseURL.Post(\u0026reqx.Request{\n\t\tURL: \"/post\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tHeaders: reqx.Headers{\n\t\t\t\"custom\": \"1\",\n\t\t},\n\t\tResult: result,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(result.Origin)\n\n\tclient := reqx.New(\n\t\treqx.WithTimeout(10*time.Second),\n\t\treqx.WithHeaders(reqx.Headers{\n\t\t\treqx.HeaderAuthorization: \"Bearer 123456\",\n\t\t}),\n\t)\n\n\t//Example Api Style\n\tresult = \u0026Response{}\n\tres, err := reqx.Post().\n\t\tURL(\"https://httpbin.org/post\").\n\t\tData(\u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t}).\n\t\tHeaders(reqx.Headers{}).\n\t\tResult(result).\n\t\tSend(client)\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(res.Headers)\n\tprintln(result.Origin)\n\n\t//POST\n\tresult = \u0026Response{}\n\tresp, err = client.Post(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/post\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tHeaders: reqx.Headers{\n\t\t\t\"custom\": \"1\",\n\t\t},\n\t\tResult: result,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(result.Origin)\n\n\t//POST and get raw body\n\tvar resultBytes []byte\n\tresp, err = client.Post(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/post\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tResult: \u0026resultBytes,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(string(resultBytes))\n\n\t//POST with request timeout\n\tvar resultBytes2 []byte\n\tresp, err = client.Post(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/post\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tResult:  \u0026resultBytes2,\n\t\tTimeout: time.Second * 5,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(string(resultBytes2))\n\n\t//UPLOAD FILES\n\ttest1Bytes, err := os.ReadFile(\"example/demo.txt\")\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\ttest2Bytes, err := os.ReadFile(\"example/demo.txt\")\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tvar resultUploadBytes []byte\n\tresp, err = client.Post(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/post\",\n\t\tData: \u0026reqx.Form{\n\t\t\tFormData: reqx.FormData{\n\t\t\t\t\"firstName\": \"reqx\",\n\t\t\t},\n\t\t\tFiles: reqx.WithFileParams(\n\t\t\t\treqx.WithFileParam(\"file1\", \"test1.pdf\", bytes.NewReader(test1Bytes)),\n\t\t\t\treqx.WithFileParam(\"file2\", \"test2.pdf\", bytes.NewReader(test2Bytes)),\n\t\t\t),\n\t\t},\n\t\tResult: \u0026resultUploadBytes,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(string(resultUploadBytes))\n\n\t//GET\n\tresult = \u0026Response{}\n\tresp, err = client.Get(\u0026reqx.Request{\n\t\tURL:    \"https://httpbin.org/get\",\n\t\tResult: result,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(result.Origin)\n\n\t//DELETE\n\tresult = \u0026Response{}\n\tresp, err = client.Delete(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/delete\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tResult: result,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(result.Origin)\n\n\t//PUT\n\tresult = \u0026Response{}\n\tresp, err = client.Put(\u0026reqx.Request{\n\t\tURL: \"https://httpbin.org/put\",\n\t\tData: \u0026Data{\n\t\t\tName: \"Reqx\",\n\t\t},\n\t\tHeaders: reqx.Headers{\n\t\t\t\"api-key\": \"123456\",\n\t\t},\n\t\tResult: result,\n\t})\n\tif err != nil {\n\t\tlog.Fatalf(err.Error())\n\t}\n\tprintln(resp.StatusCode)\n\tprintln(result.Origin)\n}\n\n```\n\n\nBuy Me a Coffee\n=======\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/dreamph)","funding_links":["https://www.buymeacoffee.com/dreamph"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Freqx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreamph%2Freqx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreamph%2Freqx/lists"}