{"id":21359293,"url":"https://github.com/alesr/httpclient","last_synced_at":"2025-03-16T06:25:38.982Z","repository":{"id":185689474,"uuid":"673952730","full_name":"alesr/httpclient","owner":"alesr","description":"A Go package for easy configuration of HTTP client settings including timeouts, connection options, and HTTP/2 configuration.","archived":false,"fork":false,"pushed_at":"2023-11-17T23:49:10.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T18:51:41.442Z","etag":null,"topics":[],"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/alesr.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}},"created_at":"2023-08-02T19:54:51.000Z","updated_at":"2024-10-18T23:01:21.000Z","dependencies_parsed_at":"2023-11-18T00:57:41.425Z","dependency_job_id":"e01a7dde-8912-4b37-b49e-ab75e3becfec","html_url":"https://github.com/alesr/httpclient","commit_stats":null,"previous_names":["alesr/httpclient"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fhttpclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fhttpclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fhttpclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fhttpclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alesr","download_url":"https://codeload.github.com/alesr/httpclient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243834959,"owners_count":20355528,"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-22T05:27:36.162Z","updated_at":"2025-03-16T06:25:38.963Z","avatar_url":"https://github.com/alesr.png","language":"Go","readme":"# HTTP Client\n\nThis package is designed to simplify the configuration of timeouts, connection options, and other settings for Go's HTTP client. It supports a variety of options, including dialer timeout, keep-alive duration, TLS handshake timeout, response header timeout, idle connection timeout, maximum idle connections, and HTTP/2 configuration.\n\n## Installation\n\nYou can import this package into your Go project using go get:\n\n```bash\ngo get github.com/alesr/httpclient\n```\n\n## Usage\n\nFirst, import the package into your Go file:\n\n```go\nimport \"github.com/alesr/httpclient\"\n```\n\nYou can create a new HTTP client with default settings as follows:\n\n```go\nclient := httpclient.New()\n```\n\nYou can modify the default configuration using the options provided by the library:\n\n```go\nclient := httpclient.New(\n    httpclient.WithTimeout(10 * time.Second),\n    httpclient.WithDialerTimeout(5 * time.Second),\n    httpclient.WithDialerKeepAlive(15 * time.Second),\n    httpclient.WithTLSHandshakeTimeout(5 * time.Second),\n    httpclient.WithResponseHeaderTimeout(10 * time.Second),\n    httpclient.WithIdleConnTimeout(15 * time.Second),\n    httpclient.WithMaxIdleConns(50),\n    httpclient.WithForceHTTP2Disabled(),\n)\n```\n\nEach option modifies a different part of the HTTP client configuration:\n\n- `WithTimeout`: sets the request timeout duration.\n- `WithDialerTimeout`: sets the dialer timeout duration.\n- `WithDialerKeepAlive`: sets the dialer keep-alive duration.\n- `WithTLSHandshakeTimeout`: sets the TLS handshake timeout duration.\n- `WithResponseHeaderTimeout`: sets the response header timeout duration.\n- `WithIdleConnTimeout`: sets the idle connection timeout duration.\n- `WithMaxIdleConns`: sets the maximum number of idle connections.\n- `WithForceHTTP2Disabled`: disables HTTP2 for the transport of the HTTP client.\n\n### Custom Transport\n\nTo use a custom transport, provide it using the WithTransport option. Note that when using a custom transport, other transport-specific options (like WithTLSHandshakeTimeout) will not apply. Ensure that your custom transport is fully configured before passing it:\n\n```go\ncustomTransport := \u0026http.Transport{\n    // Custom transport settings...\n}\nclient := httpclient.New(\n    httpclient.WithTransport(customTransport),\n)\n```\n\n### Using the Client\n\nAfter creating the client, you can use it to make HTTP requests as you would with the standard `net/http` package:\n\n```go\nresp, err := client.Get(\"http://example.com\")\n// handle error, use response...\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesr%2Fhttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falesr%2Fhttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesr%2Fhttpclient/lists"}