{"id":15733005,"url":"https://github.com/hr3lxphr6j/requests","last_synced_at":"2025-03-13T05:31:17.532Z","repository":{"id":52440222,"uuid":"277549101","full_name":"hr3lxphr6j/requests","owner":"hr3lxphr6j","description":"A \"Requests\" style HTTP client for golang","archived":false,"fork":false,"pushed_at":"2021-04-29T06:04:58.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T18:57:03.273Z","etag":null,"topics":["golang","http","http-client","requests"],"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/hr3lxphr6j.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-07-06T13:27:35.000Z","updated_at":"2023-12-29T14:25:21.000Z","dependencies_parsed_at":"2022-09-06T23:12:14.085Z","dependency_job_id":null,"html_url":"https://github.com/hr3lxphr6j/requests","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hr3lxphr6j%2Frequests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hr3lxphr6j%2Frequests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hr3lxphr6j%2Frequests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hr3lxphr6j%2Frequests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hr3lxphr6j","download_url":"https://codeload.github.com/hr3lxphr6j/requests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243351219,"owners_count":20276894,"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":["golang","http","http-client","requests"],"created_at":"2024-10-04T00:40:33.639Z","updated_at":"2025-03-13T05:31:17.050Z","avatar_url":"https://github.com/hr3lxphr6j.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Requests\n\n[![Build Status](https://travis-ci.org/hr3lxphr6j/requests.svg?branch=master)](https://travis-ci.org/hr3lxphr6j/requests)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hr3lxphr6j/requests)](https://goreportcard.com/report/github.com/hr3lxphr6j/requests)\n[![codecov](https://codecov.io/gh/hr3lxphr6j/requests/branch/master/graph/badge.svg)](https://codecov.io/gh/hr3lxphr6j/requests)\n\nA \"Requests\" style HTTP client for golang\n\n## Install\n\n```shell\ngo get -u github.com/hr3lxphr6j/requests\n```\n\n## Example\n\n```go\nvar (\n\ttimeout     = time.Second * 3\n\turl         = \"http://example.com\"\n\tqueryParams = map[string]string{\"foo\": \"bar\"}\n\tbody        = map[string]interface{}{\"a\": \"b\", \"nums\": []int{1, 2, 3}}\n)\n\n// Do `curl --connect-timeout 3 -d '{\"a\": \"b\", \"num\": [1, 2, 3]}' -H 'Content-Type: application/json' http://example.com?foo=bar`\n\n// With net/http\nfunc UseNetHttp() map[string]interface{} {\n\tctx, _ := context.WithTimeout(context.Background(), timeout)\n\tbuf := new(bytes.Buffer)\n\tif err := json.NewEncoder(buf).Encode(body); err != nil {\n\t\tlog.Panic(err)\n\t}\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost, url, buf)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tvalue := urlPkg.Values{}\n\tfor k, v := range queryParams {\n\t\tvalue.Set(k, v)\n\t}\n\treq.URL.RawQuery = value.Encode()\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tdefer resp.Body.Close()\n\tdata := map[string]interface{}{}\n\tif err := json.NewDecoder(resp.Body).Decode(\u0026data); err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn data\n}\n\n// With Requests\nfunc UseRequests() map[string]interface{} {\n\tresp, err := requests.Post(url,\n\t\trequests.Timeout(timeout),\n\t\trequests.Queries(queryParams),\n\t\trequests.JSON(body),\n\t)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tdata := map[string]interface{}{}\n\tif err := resp.JSON(\u0026data); err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn data\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhr3lxphr6j%2Frequests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhr3lxphr6j%2Frequests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhr3lxphr6j%2Frequests/lists"}