Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k1low/curlreq
curlreq creates *http.Request from curl command.
https://github.com/k1low/curlreq
curl http-request parser
Last synced: 19 days ago
JSON representation
curlreq creates *http.Request from curl command.
- Host: GitHub
- URL: https://github.com/k1low/curlreq
- Owner: k1LoW
- License: mit
- Created: 2022-10-14T13:04:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-16T05:46:06.000Z (9 months ago)
- Last Synced: 2024-10-06T04:16:39.406Z (about 1 month ago)
- Topics: curl, http-request, parser
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# curlreq
[![build](https://github.com/k1LoW/curlreq/actions/workflows/ci.yml/badge.svg)](https://github.com/k1LoW/curlreq/actions/workflows/ci.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/k1LoW/curlreq.svg)](https://pkg.go.dev/github.com/k1LoW/curlreq) ![Coverage](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/curlreq/coverage.svg) ![Code to Test Ratio](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/curlreq/ratio.svg) ![Test Execution Time](https://raw.githubusercontent.com/k1LoW/octocovs/main/badges/k1LoW/curlreq/time.svg)
`curlreq` creates `*http.Request` from [curl](https://curl.se/) command.
## Usage
```go
package mainimport (
"fmt"
"log"
"net/http""github.com/k1LoW/curlreq"
)func main() {
cmd := "curl https://example.com"
req, err := curlreq.NewRequest(cmd)
if err != nil {
log.Fatal(err)
}
client := http.DefaultClient
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()fmt.Println(resp.StatusCode)
// Output:
// 200
}
```## Reference
- [tj/parse-curl.js](https://github.com/tj/parse-curl.js): Parse curl commands, returning an object representing the request.