...
1# http2curl
2
3:triangular_ruler: Convert Golang's http.Request to CURL command line
4
5[](https://pkg.go.dev/moul.io/http2curl)
6[](https://github.com/moul/http2curl/blob/master/COPYRIGHT)
7[](https://github.com/moul/http2curl/releases)
8[](https://microbadger.com/images/moul/http2curl)
9[](https://manfred.life/)
10
11[](https://github.com/moul/http2curl/actions?query=workflow%3AGo)
12[](https://github.com/moul/http2curl/actions?query=workflow%3ARelease)
13[](https://github.com/moul/http2curl/actions?query=workflow%3APR)
14[](https://golangci.com/r/github.com/moul/http2curl)
15[](https://codecov.io/gh/moul/http2curl)
16[](https://goreportcard.com/report/moul.io/http2curl)
17[](https://www.codefactor.io/repository/github/moul/http2curl)
18
19To do the reverse operation, check out [mholt/curl-to-go](https://github.com/mholt/curl-to-go).
20
21## Example
22
23```go
24import (
25 "http"
26 "moul.io/http2curl"
27)
28
29data := bytes.NewBufferString(`{"hello":"world","answer":42}`)
30req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", data)
31req.Header.Set("Content-Type", "application/json")
32
33command, _ := http2curl.GetCurlCommand(req)
34fmt.Println(command)
35// Output: curl -X PUT -d "{\"hello\":\"world\",\"answer\":42}" -H "Content-Type: application/json" http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu
36```
37
38## Install
39
40```bash
41go get moul.io/http2curl
42```
43
44## Usages
45
46- https://github.com/parnurzeal/gorequest
47- https://github.com/scaleway/scaleway-cli
48- https://github.com/nmonterroso/cowsay-slackapp
49- https://github.com/moul/as-a-service
50- https://github.com/gavv/httpexpect
51- https://github.com/smallnest/goreq
52
53## License
54
55© 2019-2021 [Manfred Touron](https://manfred.life)
56
57Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([`LICENSE-APACHE`](LICENSE-APACHE)) or the [MIT license](https://opensource.org/licenses/MIT) ([`LICENSE-MIT`](LICENSE-MIT)), at your option. See the [`COPYRIGHT`](COPYRIGHT) file for more details.
58
59`SPDX-License-Identifier: (Apache-2.0 OR MIT)`
View as plain text