{"id":13413648,"url":"https://github.com/wenerme/go-req","last_synced_at":"2025-09-05T18:32:00.327Z","repository":{"id":40690007,"uuid":"384922385","full_name":"wenerme/go-req","owner":"wenerme","description":"Declarative golang HTTP client","archived":false,"fork":false,"pushed_at":"2022-07-06T11:07:02.000Z","size":28,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-23T18:13:16.597Z","etag":null,"topics":["client","golang","http"],"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/wenerme.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":"2021-07-11T10:42:40.000Z","updated_at":"2024-10-28T14:34:27.000Z","dependencies_parsed_at":"2022-09-07T10:42:17.495Z","dependency_job_id":null,"html_url":"https://github.com/wenerme/go-req","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/wenerme%2Fgo-req","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenerme%2Fgo-req/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenerme%2Fgo-req/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenerme%2Fgo-req/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenerme","download_url":"https://codeload.github.com/wenerme/go-req/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232052267,"owners_count":18465727,"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","golang","http"],"created_at":"2024-07-30T20:01:45.383Z","updated_at":"2025-01-01T06:14:36.381Z","avatar_url":"https://github.com/wenerme.png","language":"Go","funding_links":[],"categories":["Networking","网络","HTTP Clients"],"sub_categories":["HTTP Clients","HTTP客户端"],"readme":"# go-req\n\n[![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov]  [![Go Report Card][report-card-img]][report-card]\n\n[doc-img]: https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square\n[doc]: https://pkg.go.dev/github.com/wenerme/go-req?tab=doc\n[ci-img]: https://github.com/wenerme/go-req/actions/workflows/ci.yml/badge.svg\n[ci]: https://github.com/wenerme/go-req/actions/workflows/ci.yml\n[cov-img]: https://codecov.io/gh/wenerme/go-req/branch/main/graph/badge.svg\n[cov]: https://codecov.io/gh/wenerme/go-req/branch/main\n[report-card-img]: https://goreportcard.com/badge/github.com/wenerme/go-req\n[report-card]: https://goreportcard.com/report/github.com/wenerme/go-req\n\nDeclarative golang HTTP client\n\n```go\npackage req_test\n\nimport (\n    \"fmt\"\n    \"github.com/wenerme/go-req\"\n    \"net/http\"\n)\n\nfunc ExampleRequest() {\n    // reusable client\n    client := req.Request{\n        BaseURL: \"https://httpbin.org\",\n        Options: []interface{}{req.JSONEncode, req.JSONDecode},\n    }\n  \n    // dump request and response with body\n    client = client.WithHook(req.DebugHook(\u0026req.DebugOptions{Body: true}))\n    \n    // send request with declarative override\n    var out PostResponse\n    var r *http.Response\n    err := client.With(req.Request{\n        Method: http.MethodPost,\n        URL: \"/post\",\n        Body: HelloRequest{\n          Name: \"go-req\",\n        },\n    }).Fetch(\u0026out,\u0026r)\n    if err != nil {\n      panic(err)\n    }\n    // print go-req\n    fmt.Println(out.JSON.Name)\n    // print 200\n    fmt.Println(r.StatusCode)\n}\n\ntype HelloRequest struct {\n  Name string\n}\ntype HelloResponse struct {\n  Name string\n}\ntype PostResponse struct {\n  JSON HelloResponse `json:\"json\"`\n}\n```\n\n## Used by\n\n- [wenerme/go-wecom](https://github.com/wenerme/go-wecom)\n  - Wechat Work/Wecom/企业微信 Golang SDK\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenerme%2Fgo-req","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenerme%2Fgo-req","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenerme%2Fgo-req/lists"}