{"id":13590409,"url":"https://github.com/li-jin-gou/http2curl","last_synced_at":"2025-03-17T06:31:24.208Z","repository":{"id":65662273,"uuid":"596373317","full_name":"li-jin-gou/http2curl","owner":"li-jin-gou","description":"convert Request of fasthttp、hertz and resty to CURL command line","archived":false,"fork":false,"pushed_at":"2024-06-02T15:09:31.000Z","size":28,"stargazers_count":40,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-27T18:58:36.970Z","etag":null,"topics":["curl","fasthttp","hertz","resty"],"latest_commit_sha":null,"homepage":"","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/li-jin-gou.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-02T03:12:12.000Z","updated_at":"2025-02-27T18:01:31.000Z","dependencies_parsed_at":"2024-06-02T16:57:56.436Z","dependency_job_id":"c19fc057-3cff-4322-90ab-e8d6af2eabfc","html_url":"https://github.com/li-jin-gou/http2curl","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-jin-gou%2Fhttp2curl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-jin-gou%2Fhttp2curl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-jin-gou%2Fhttp2curl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-jin-gou%2Fhttp2curl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/li-jin-gou","download_url":"https://codeload.github.com/li-jin-gou/http2curl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847060,"owners_count":20357317,"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":["curl","fasthttp","hertz","resty"],"created_at":"2024-08-01T16:00:44.954Z","updated_at":"2025-03-17T06:31:23.810Z","avatar_url":"https://github.com/li-jin-gou.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# http2curl\n\nconvert Request of [fasthttp](https://github.com/valyala/fasthttp), [hertz](https://github.com/cloudwego/hertz) and net/http to CURL command line and fork from [moul/http2curl](https://github.com/moul/http2curl)\n\n\n# Install\n\n```shell\ngo get github.com/li-jin-gou/http2curl\n```\n\n## Usage\n\n\n### FastHttp\n\n```go\nfunc FastHttpDemo() {\n\t// fasthttp\n\tvar req fasthttp.Request\n\treq.SetRequestURI(\"https://example.com/index\")\n\treq.Header.SetMethod(fasthttp.MethodPost)\n\treq.SetBody([]byte(`{\"a\":\"b\"}`))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tc, _ := http2curl.GetCurlCommandFastHttp(\u0026req)\n\tfmt.Println(c)\n\t// Output: curl -k -X 'POST' -d '{\"a\":\"b\"}' -H 'Content-Type: application/json' 'https://example.com/index' --compressed\n}\n\n```\n\n### Hertz\n\n```go\nfunc HertzDemo() {\n\t// hertz\n\treq := protocol.NewRequest(consts.MethodGet, \"https://example.com/index\", nil)\n\treq.URI().QueryArgs().Add(\"a\", \"1\")\n\treq.URI().QueryArgs().Add(\"b\", \"2\")\n\treq.Header.Set(\"a\", \"2\")\n\tc, _ := http2curl.GetCurlCommandHertz(req)\n\tfmt.Println(c)\n\t// Output: curl -k -X 'GET' -H 'A: 2' -H 'Host: example.com' 'https://example.com/index?a=1\u0026b=2' --compressed\n}\n```\n\n### net/http\n\n```go\nfunc NetHttpDemo() {\n\treq, _ := http.NewRequest(http.MethodPost, \"https://example.com/index\", bytes.NewBufferString(`{\"a\":\"b\"}`))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tc, _ := http2curl.GetCurlCommand(req)\n\tfmt.Println(c)\n\t// Output: curl -k -X 'POST' -d '{\"a\":\"b\"}' -H 'Content-Type: application/json' 'https://example.com/index' --compressed\n}\n```\n\n### Resty\n\n```go\nfunc RestyDemo() {\n\tvar req *resty.Request\n\tclient := resty.New()\n\tresp, _ := client.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetBody([]byte(`{\"a\":\"b\"}`)).\n\t\tPost(\"https://example.com/index\")\n\treq = resp.Request\n\tc, _ := http2curl.GetCurlCommandResty(req)\n\tfmt.Println(c)\n\t// Output: curl -k -X 'POST' -d '{\"a\":\"b\"}' -H 'Accept: application/json' -H 'Content-Type: application/json' -H 'User-Agent: go-resty/2.12.0 (https://github.com/go-resty/resty)' 'https://example.com/index' --compressed\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-jin-gou%2Fhttp2curl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fli-jin-gou%2Fhttp2curl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-jin-gou%2Fhttp2curl/lists"}