{"id":21275679,"url":"https://github.com/halimath/httpclient","last_synced_at":"2025-03-15T13:13:44.616Z","repository":{"id":61629314,"uuid":"552817283","full_name":"halimath/httpclient","owner":"halimath","description":"Convenient http client for golang based on net/http","archived":false,"fork":false,"pushed_at":"2022-10-17T18:06:48.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T03:27:44.016Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/halimath.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":"2022-10-17T09:18:53.000Z","updated_at":"2022-10-17T09:19:30.000Z","dependencies_parsed_at":"2022-10-18T17:45:25.519Z","dependency_job_id":null,"html_url":"https://github.com/halimath/httpclient","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fhttpclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fhttpclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fhttpclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halimath%2Fhttpclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halimath","download_url":"https://codeload.github.com/halimath/httpclient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732303,"owners_count":20338839,"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-21T09:36:08.770Z","updated_at":"2025-03-15T13:13:44.595Z","avatar_url":"https://github.com/halimath.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# httpclient\n\n![CI Status][ci-img-url] [![Go Report Card][go-report-card-img-url]][go-report-card-url]\n[![Package Doc][package-doc-img-url]][package-doc-url] [![Releases][release-img-url]][release-url]\n\n[ci-img-url]: https://github.com/halimath/httpclient/workflows/CI/badge.svg\n[go-report-card-img-url]: https://goreportcard.com/badge/github.com/halimath/httpclient\n[go-report-card-url]: https://goreportcard.com/report/github.com/halimath/httpclient\n[package-doc-img-url]: https://img.shields.io/badge/GoDoc-Reference-blue.svg\n[package-doc-url]: https://pkg.go.dev/github.com/halimath/httpclient\n[release-img-url]: https://img.shields.io/github/v/release/halimath/httpclient.svg\n[release-url]: https://github.com/halimath/httpclient/releases\n\n`httpclient` provides a convenient http client library for the go programming language which is completely\nbased and compatible with the standard lib's `net/http` package but adds commonly used functionality in a\nsimple API.\n\n# Usage\n\n## Installation\n\n`httpclient` uses go modules and requires Go 1.18 or greater.\n\n```\n$ go get -u github.com/halimath/httpclient\n```\n## Making requests\n\nMaking simple requests requires a `httpclient.Client`. This package provides no package level functions.\n\n```go\nc := httpclient.New(httpclient.WithURLPrefix(\"https://httpbin.org\"))\nctx := context.Background()\nres, err := c.Get(ctx, \"/status/204\")\n```\n\nA central piece of `httpclient` is the use of _interceptors_ to handle requests and \nresponses. This allows you to add additional information to a request or \"spy\" on \nresponse values. `httpclient` provides a couple of common interceptors. Adding request\nheaders and handline response bodies becomes very easy:\n\n```go\nc := httpclient.New(\n\thttpclient.WithURLPrefix(\"https://httpbin.org\"),\n\thttpclient.ExpectedStatusCode(http.StatusOK),\n)\n\nvar userAgent struct {\n\tUserAgent string `json:\"user-agent\"`\n}\n\nctx := context.Background()\nres, err := c.Get(ctx, \"/user-agent\",\n\thttpclient.WithRequestHeader(\"User-Agent\", \"httpclient/1.0\"),\n\thttpclient.ForJSON(\u0026userAgent),\n)\n```\n\nAs you can add interceptors both on the request as well as on the client level, common\nthings (such as handling error status codes) can easily be defined globally.\n\nYou can also provide your own interceptors by implementing either \n`httpclient.RequestInterceptor` or `httpclient.ResponseInterceptor`.\n\n# Changelog\n\n## 0.1.0\n* Initial release\n\n# License\n\n```\nCopyright 2022 Alexander Metzner.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fhttpclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalimath%2Fhttpclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalimath%2Fhttpclient/lists"}