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