Install
go get github.com/0x204/cfparser
Example of usage
Simple GET
package main
import (
"fmt"
"io"
http "github.com/bogdanfinn/fhttp"
"github.com/0x204/cfparser/src"
)
func main() {
client := &http.Client{}
client.Transport, _ = src.New(client.Transport)
resp, _ := client.Get("https://example.com")
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Customize request
req, _ := http.NewRequest(http.MethodGet, "https://example.com/api", nil)
req.Header.Set("X-Custom-Header", "value")
req.Header.Set("Accept", "application/json")
req.Header.Set("Referer", "https://google.com")
resp, _ := client.Do(req)
POST with JSON body
payload := `{"key":"value"}`
req, _ := http.NewRequest(http.MethodPost, "https://example.com/api", bytes.NewBuffer([]byte(payload)))
req.Header.Set("Content-Type", "application/json")
resp, _ := client.Do(req)