{"id":18310963,"url":"https://github.com/cploutarchou/go-requests","last_synced_at":"2025-04-09T12:10:47.291Z","repository":{"id":61679893,"uuid":"551077640","full_name":"cploutarchou/go-requests","owner":"cploutarchou","description":"An HTTP client that is ready for production in Go for a lot of useful features while only using the standard library of the language.","archived":false,"fork":false,"pushed_at":"2023-01-13T13:45:20.000Z","size":3768,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T05:46:40.339Z","etag":null,"topics":["client-library","go","golang","golang-library","golang-package","http","http-client","http-requests","rest-api"],"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/cploutarchou.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-13T20:01:36.000Z","updated_at":"2023-01-25T15:37:31.000Z","dependencies_parsed_at":"2023-02-09T15:46:39.123Z","dependency_job_id":null,"html_url":"https://github.com/cploutarchou/go-requests","commit_stats":null,"previous_names":["cploutarchou/requests","cploutarchou/go-http"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cploutarchou%2Fgo-requests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cploutarchou%2Fgo-requests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cploutarchou%2Fgo-requests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cploutarchou%2Fgo-requests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cploutarchou","download_url":"https://codeload.github.com/cploutarchou/go-requests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036066,"owners_count":21037092,"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-library","go","golang","golang-library","golang-package","http","http-client","http-requests","rest-api"],"created_at":"2024-11-05T16:16:01.669Z","updated_at":"2025-04-09T12:10:47.272Z","avatar_url":"https://github.com/cploutarchou.png","language":"Go","funding_links":["https://www.buymeacoffee.com/cploutarchou","https://paypal.me/cploutarchou","https://ko-fi.com/cploutarchou"],"categories":[],"sub_categories":[],"readme":"# go-requests an HTTP client for Go\n_________\n\nAn HTTP client that is ready for production in Go for a lot of useful features while only using the standard library of the language.\n## Installation\nTo use the library for HTTP calls, you must first import the corresponding HTTP package:\n```bash\ngo get github.com/cploutarchou/go-requests\n``` \n    \n## Usage\n________________________\n### Import the package :\n\n```go\n    import requests \"github.com/cploutarchou/go-requests\"\n\n```\n### Client\n1. Create a new client with the default configuration\n```go\n\tbuilder := requests.NewBuilder()\n\tclient := builder.Build()\n```\n2. Create a  new client with a custom configuration\n```go\n\tbuilder := requests.NewBuilder()\n\t\n\tbuilder.Headers().\n\t\tSetContentType(\"application/json\").\n        SetAccept(\"application/json\").\n        SetUserAgent(\"go-requests\")\n        builder.SetRequestTimeout(10 * time.Second).\n        SetResponseTimeout(10 * time.Second).\n        SetMaxIdleConnections(10)\n\tclient := builder.Build()\n```\n3. Create a new client with our own http.Client\n```go\n\tcustomClient := \u0026http.Client{\n\tTimeout: 10 * time.Second, \n\tTransport: \u0026http.Transport{\n\t\tMaxIdleConnsPerHost:   10, \n\t\tResponseHeaderTimeout: 10 * time.Second, \n\t\tDialContext: (\u0026net.Dialer{\n\t\t\tTimeout: 10 * time.Second,\n\t\t}).DialContext,\n\t},\n\t}\n\tbuilder := requests.NewBuilder()\n\tbuilder.Headers().\n\t\tSetContentType(\"application/json\").\n\t\tSetAccept(\"application/json\").SetUserAgent(\"go-requests\")\n\tbuilder.SetHTTPClient(customClient)\n\tclient := builder.Build()\n```\n____________________\n### Requests\n####  GET \n```go\n    type PetTag struct {\n\t    PhotoUrls []string `json:\"photoUrls\"`\n\t    Name      string   `json:\"name\"`\n\t    ID        int64    `json:\"id\"`\n\t    Category  struct {\n\t\t    Name string `json:\"name\"`\n\t\t    ID   int64  `json:\"id\"`\n\t    } `json:\"category\"`\n\t    Tags []struct {\n\t\t    Name string `json:\"name\"`\n\t\t    ID   int64  `json:\"id\"`\n\t    } `json:\"tags\"`\n\t    Status string `json:\"status\"`\n\t}\n\n\ttype PetsTags []PetTag\n        tags := \"dogs,cats\"\n\t\n\tclient.QueryParams().Set(\"tags\", tags)\n\tresp, err := jsonContentClient.Get(\"https://request-url.com/pet/findByTags\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tvar pets PetsTags\n\t// Unmarshal the response body into the struct we support the JSON, XML, YAML,Text formats\n\terr = resp.Unmarshal(\u0026pets)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tfmt.Println(string(pets))\n```\n\n## For more examples, see the [examples](https://github.com/cploutarchou/go-requests/tree/master/examples) directory.\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\nPlease make sure to update tests as appropriate.\n## License\n[MIT](https://github.com/cploutarchou/go-requests/blob/master/LICENSE)\n\n### 💰 You can help me by Donating\n[![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://www.buymeacoffee.com/cploutarchou) [![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge\u0026logo=paypal\u0026logoColor=white)](https://paypal.me/cploutarchou) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/cploutarchou) \n\n### Thanks for your support! 🙏\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcploutarchou%2Fgo-requests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcploutarchou%2Fgo-requests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcploutarchou%2Fgo-requests/lists"}