https://github.com/prongbang/callx
CallX HTTP Client easy call API for Golang
https://github.com/prongbang/callx
callx go go-callx go-http-client golang http http-client
Last synced: about 1 month ago
JSON representation
CallX HTTP Client easy call API for Golang
- Host: GitHub
- URL: https://github.com/prongbang/callx
- Owner: prongbang
- License: mit
- Created: 2020-06-27T17:58:39.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-19T16:36:00.000Z (over 1 year ago)
- Last Synced: 2025-03-07T20:18:48.579Z (about 1 year ago)
- Topics: callx, go, go-callx, go-http-client, golang, http, http-client
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CallX ๐
[](https://codecov.io/gh/prongbang/callx)
[](https://goreportcard.com/report/github.com/prongbang/callx)
[](https://pkg.go.dev/github.com/prongbang/callx)
[](https://opensource.org/licenses/MIT)
> A lightweight, fast, and easy-to-use HTTP client for Go. Make API calls with just a few lines of code!
## โจ Features
- ๐ **Ultra-fast performance** - Optimized for speed
- ๐ **Simple API** - Easy to learn and use
- ๐ง **Highly customizable** - Full control over requests
- ๐งช **Well tested** - High test coverage
## โก๏ธ Performance
CallX is designed for optimal performance. Here are the benchmark results:
| HTTP Method | Operations | Time per Operation |
|-------------|------------|-------------------|
| GET | 41,756 | 31,823 ns/op |
| POST | 38,692 | 35,787 ns/op |
| POST-ENCODE | 28,848 | 39,314 ns/op |
| PUT | 31,401 | 35,046 ns/op |
| PATCH | 38,923 | 30,094 ns/op |
| DELETE | 41,100 | 29,195 ns/op |
## ๐ฆ Installation
```bash
go get github.com/prongbang/callx
```
## ๐ Quick Start
### Basic Usage
```go
// Create a client with base URL
c := callx.Config{
BaseURL: "https://jsonplaceholder.typicode.com",
Timeout: 60,
}
req := callx.New(c)
// Make a GET request
data := req.Get("/todos/1")
fmt.Println(string(data.Data))
```
## ๐ฅ Advanced Features
### Custom Request with Authentication
```go
c := callx.Config{
Timeout: 60,
}
req := callx.New(c)
custom := callx.Custom{
URL: "https://httpbin.org/post",
Method: http.MethodPost,
Header: callx.Header{
callx.Authorization: fmt.Sprintf("%s %s", callx.Bearer, "your-token"),
},
Body: callx.Body{
"username": "root",
"password": "pass",
"address": []string{
"087654321",
"089786756",
},
},
}
data := req.Req(custom)
fmt.Println(string(data.Data))
```
### Form-encoded Requests
```go
c := callx.Config{
Timeout: 60,
}
req := callx.New(c)
form := url.Values{}
form.Set("message", "Test")
custom := callx.Custom{
URL: "https://httpbin.org/post",
Method: http.MethodPost,
Header: callx.Header{
callx.Authorization: "Bearer XTZ",
callx.ContentType: "application/x-www-form-urlencoded",
},
Form: strings.NewReader(form.Encode()),
}
data := req.Req(custom)
fmt.Println(string(data.Data))
```