📐 Convert Golang's http.Request to CURL command line
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Godeps Revert "Remove testing dependencies" Oct 24, 2016
vendor/github.com go fmt applied Sep 19, 2017
.gitignore
.travis.yml
LICENSE
Makefile
README.md Add more usage links Oct 31, 2016
http2curl.go Bash escaping and more tests Oct 23, 2016
http2curl_test.go

README.md

http2curl

📐 Convert Golang's http.Request to CURL command line

Build Status GoDoc Coverage Status

To do the reverse, check out mholt/curl-to-go.

Example

import "http"
import "github.com/moul/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

$ go get github.com/moul/http2curl

Usages

License

MIT