{"id":13756385,"url":"https://github.com/mozillazg/request","last_synced_at":"2025-06-26T03:04:53.392Z","repository":{"id":24872577,"uuid":"28288319","full_name":"mozillazg/request","owner":"mozillazg","description":"A developer-friendly HTTP request library for Gopher.","archived":false,"fork":false,"pushed_at":"2019-12-05T09:11:26.000Z","size":219,"stargazers_count":426,"open_issues_count":6,"forks_count":37,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-01-05T18:15:20.885Z","etag":null,"topics":["go","golang","http","request"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/mozillazg/request","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/mozillazg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T04:30:42.000Z","updated_at":"2024-12-05T13:30:43.000Z","dependencies_parsed_at":"2022-08-23T09:11:05.177Z","dependency_job_id":null,"html_url":"https://github.com/mozillazg/request","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/mozillazg/request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Frequest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Frequest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Frequest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Frequest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mozillazg","download_url":"https://codeload.github.com/mozillazg/request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mozillazg%2Frequest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261990349,"owners_count":23241188,"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":["go","golang","http","request"],"created_at":"2024-08-03T11:00:43.284Z","updated_at":"2025-06-26T03:04:53.365Z","avatar_url":"https://github.com/mozillazg.png","language":"Go","funding_links":[],"categories":["Utilities","公用事业公司","Go","工具库","实用工具","工具库`可以提升效率的通用代码库和工具`","實用工具","Utility"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","HTTP Clients","Advanced Console UIs","查询语","高級控制台界面","高级控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流","Fail injection"],"readme":"request\n=======\n[![Build Status](https://travis-ci.org/mozillazg/request.svg?branch=master)](https://travis-ci.org/mozillazg/request)\n[![Coverage Status](https://coveralls.io/repos/mozillazg/request/badge.png?branch=master)](https://coveralls.io/r/mozillazg/request?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mozillazg/request)](https://goreportcard.com/report/github.com/mozillazg/request)\n[![GoDoc](https://godoc.org/github.com/mozillazg/request?status.svg)](https://godoc.org/github.com/mozillazg/request)\n\nA developer-friendly HTTP request library for Gopher. Inspired by [Python-Requests](https://github.com/kennethreitz/requests).\n\n\nInstallation\n------------\n\n```\ngo get -u github.com/mozillazg/request\n```\n\n\nDocumentation\n--------------\n\nAPI documentation can be found here:\nhttps://godoc.org/github.com/mozillazg/request\n\n\nUsage\n-------\n\n```go\nimport (\n    \"github.com/mozillazg/request\"\n)\n```\n\n**GET**:\n\n```go\nc := new(http.Client)\nreq := request.NewRequest(c)\nresp, err := req.Get(\"http://httpbin.org/get\")\nj, err := resp.Json()\ndefer resp.Body.Close()  // Don't forget close the response body\n```\n\n**POST**:\n\n```go\nreq := request.NewRequest(c)\nreq.Data = map[string]string{\n    \"key\": \"value\",\n    \"a\":   \"123\",\n}\nresp, err := req.Post(\"http://httpbin.org/post\")\n```\n\n**Cookies**:\n\n```go\nreq := request.NewRequest(c)\nreq.Cookies = map[string]string{\n    \"key\": \"value\",\n    \"a\":   \"123\",\n}\nresp, err := req.Get(\"http://httpbin.org/cookies\")\n```\n\n**Headers**:\n\n```go\nreq := request.NewRequest(c)\nreq.Headers = map[string]string{\n    \"Accept-Encoding\": \"gzip,deflate,sdch\",\n    \"Accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\",\n}\nresp, err := req.Get(\"http://httpbin.org/get\")\n```\n\n**Files**:\n\n```go\nreq := request.NewRequest(c)\nf, err := os.Open(\"test.txt\")\nreq.Files = []request.FileField{\n    request.FileField{\"file\", \"test.txt\", f},\n}\nresp, err := req.Post(\"http://httpbin.org/post\")\n```\n\n**Json**:\n\n```go\nreq := request.NewRequest(c)\nreq.Json = map[string]string{\n    \"a\": \"A\",\n    \"b\": \"B\",\n}\nresp, err := req.Post(\"http://httpbin.org/post\")\nreq.Json = []int{1, 2, 3}\nresp, err = req.Post(\"http://httpbin.org/post\")\n```\n\n**Proxy**:\n```go\nreq := request.NewRequest(c)\nreq.Proxy = \"http://127.0.0.1:8080\"\n// req.Proxy = \"https://127.0.0.1:8080\"\n// req.Proxy = \"socks5://127.0.0.1:57341\"\nresp, err := req.Get(\"http://httpbin.org/get\")\n```\nor https://github.com/mozillazg/request/tree/develop/_example/proxy\n\n**HTTP Basic Authentication**:\n```go\nreq := request.NewRequest(c)\nreq.BasicAuth = request.BasicAuth{\"user\", \"passwd\"}\nresp, err := req.Get(\"http://httpbin.org/basic-auth/user/passwd\")\n```\n\n\nLicense\n---------\n\nUnder the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2Frequest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmozillazg%2Frequest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmozillazg%2Frequest/lists"}