Convert fasthttp.Request to CURL command line
import (
"fmt"
"github.com/valyala/fasthttp"
"github.com/andot/fasthttp2curl"
)
req := fasthttp.AcquireRequest()
req.Header.SetMethod(fasthttp.MethodPut)
req.SetRequestURI("http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu")
req.SetBodyString(`{"hello":"world","answer":42}`)
req.Header.SetContentType("application/json")
command := GetCurlCommand(req)
fasthttp.ReleaseRequest(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'
go get github.com/andot/fasthttp2curl
© 2022 Ma Bingyao
Licensed under the MIT license (LICENSE-MIT
).