{"id":26157916,"url":"https://github.com/mediabuyerbot/httpclient","last_synced_at":"2025-12-16T12:03:20.720Z","repository":{"id":57515928,"uuid":"244876352","full_name":"mediabuyerbot/httpclient","owner":"mediabuyerbot","description":"HTTP client for golang","archived":false,"fork":false,"pushed_at":"2020-03-04T20:57:48.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-13T07:27:04.499Z","etag":null,"topics":["api-client","curl","golang","golang-library","httpcli","httpclient","rest"],"latest_commit_sha":null,"homepage":null,"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/mediabuyerbot.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":"2020-03-04T10:52:28.000Z","updated_at":"2022-11-09T18:06:34.000Z","dependencies_parsed_at":"2022-08-28T17:33:57.893Z","dependency_job_id":null,"html_url":"https://github.com/mediabuyerbot/httpclient","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mediabuyerbot%2Fhttpclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mediabuyerbot%2Fhttpclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mediabuyerbot%2Fhttpclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mediabuyerbot%2Fhttpclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mediabuyerbot","download_url":"https://codeload.github.com/mediabuyerbot/httpclient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243014895,"owners_count":20221976,"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":["api-client","curl","golang","golang-library","httpcli","httpclient","rest"],"created_at":"2025-03-11T10:29:08.168Z","updated_at":"2025-12-16T12:03:20.625Z","avatar_url":"https://github.com/mediabuyerbot.png","language":"Go","readme":"# httpclient  [![Coverage Status](https://coveralls.io/repos/github/mediabuyerbot/httpclient/badge.svg?branch=master)](https://coveralls.io/github/mediabuyerbot/httpclient?branch=master)\n\n## Table of contents\n- [Installation](#installation)\n- [Commands](#commands)\n  + [Build dependencies](#build-dependencies)\n  + [Run test](#run-test)\n  + [Run test with coverage profile](#run-test-with-coverage-profile) \n  + [Run sync coveralls](#run-sync-coveralls)\n  + [Build mocks](#build-mocks) \n- [Usage](#usage)\n  + [Making a GET request](#making-a-get-request)\n  + [Making a GET request with headers](#making-a-get-request-with-headers) \n  + [Making a POST request](#making-a-post-request)\n  + [Making a POST request with headers](#making-a-post-request-with-headers)\n  + [Making a PUT request](#making-a-put-request)\n  + [Making a PUT request with headers](#making-a-put-request-with-headers)\n  + [Making a DELETE request](#making-a-delete-request)\n  + [Making a DELETE request with headers](#making-a-delete-request-with-headers)\n  + [Making a CUSTOM request](#making-a-custom-request)\n- [Options](#options)\n     \n### Installation\n```shell script\ngo get github.com/mediabuyerbot/httpclient\n```\n\n### Commands\n#### Build dependencies\n```shell script\nmake deps\n```\n\n#### Run test\n```shell script\nmake test\n```\n\n#### Run test with coverage profile\n```shell script\nmake covertest\n```\n#### Run sync coveralls\n```shell script\nCOVERALLS_HTTPCLIENT_TOKEN=${COVERALLS_REPO_TOKEN}\nmake sync-coveralls\n```\n#### Build mocks\n```shell script\nmake mocks\n```\n\n### Usage\n#### Making a GET request \n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nresp, err := cli.Get(context.TODO(), \"https://google.com\", nil)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a GET request with headers\n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nheaders := make(http.Header)\nheaders.Add(\"X-Header\", \"value\")\nresp, err := cli.Get(context.TODO(), \"https://google.com\", headers)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a POST request \n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\npayload := ioutil.NopCloser(bytes.NewReader([]byte(`payload`)))\nresp, err := cli.Post(context.TODO(), payload, \"https://google.com\", nil)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a POST request with headers\n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nheaders := make(http.Header)\nheaders.Add(\"X-Header\", \"value\")\npayload := ioutil.NopCloser(bytes.NewReader([]byte(`payload`)))\nresp, err := cli.POST(context.TODO(), payload, \"https://google.com\", headers)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a PUT request \n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\npayload := ioutil.NopCloser(bytes.NewReader([]byte(`payload`)))\nresp, err := cli.PUT(context.TODO(), payload, \"https://google.com\", nil)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a PUT request with headers\n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nheaders := make(http.Header)\nheaders.Add(\"X-Header\", \"value\")\npayload := ioutil.NopCloser(bytes.NewReader([]byte(`payload`)))\nresp, err := cli.PUT(context.TODO(), payload, \"https://google.com\", headers)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a DELETE request \n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nresp, err := cli.Delete(context.TODO(), \"https://google.com\", nil)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a DELETE request with headers\n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nheaders := make(http.Header)\nheaders.Add(\"X-Header\", \"value\")\nresp, err := cli.Delete(context.TODO(), \"https://google.com\", headers)\nif err != nil {\n    panic(err)\n}\n...\n```\n\n#### Making a CUSTOM request\n```go\ncli, err := New()\nif err != nil {\n    panic(err)\n}\nreq, err := http.NewRequest(http.MethodHead, \"https://google.com\", nil)\nif err != nil {\n    panic(err) \n}\nresp, err := cli.Do(req)\nif err != nil {\n    panic(err)\n}\n...\n``` \n\n### Options\n```go\n_, err := New(\n   WithTimeout(time.Second),\n   WithRetryCount(2),\n   WithRequestHook(func(request *http.Request, i int) {})   \n   WithResponseHook(func(request *http.Request, response *http.Response) {}),\n   WithCheckRetry(func(req *http.Request, resp *http.Response, err error) (bool, error) {}),\n   WithBackOff(func(attemptNum int, resp *http.Response) time.Duration {}),\n   WithErrorHook(func(req *http.Request, err error, retry int) {}),\n   WithErrorHandler(func(resp *http.Response, err error, numTries int) (*http.Response, error) {}),\n   WithBaseURL(\"http://127.0.0.1\"),  \n)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmediabuyerbot%2Fhttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmediabuyerbot%2Fhttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmediabuyerbot%2Fhttpclient/lists"}