https://github.com/dmdhrumilmistry/fasthttpclient
fasthttpclient makes it easy for devs to make HTTP calls.
https://github.com/dmdhrumilmistry/fasthttpclient
fasthttp fasthttpclient go golang
Last synced: about 1 year ago
JSON representation
fasthttpclient makes it easy for devs to make HTTP calls.
- Host: GitHub
- URL: https://github.com/dmdhrumilmistry/fasthttpclient
- Owner: dmdhrumilmistry
- License: mit
- Created: 2024-05-28T17:10:23.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-15T09:01:56.000Z (over 1 year ago)
- Last Synced: 2025-03-28T05:42:21.047Z (about 1 year ago)
- Topics: fasthttp, fasthttpclient, go, golang
- Language: Go
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastHttpClient
[](https://github.com/dmdhrumilmistry/fasthttpclient/blob/master/LICENSE)
FastHttpClient is a lightweight and high-performance HTTP client for sending requests.
## Features
- Simple and intuitive API
- Fast and efficient
- Supports various HTTP methods (GET, POST, PUT, DELETE, etc.)
- Use as Package
- Client with Rate Limiting option
## Usage
- Add project to dependency
```bash
go get github.com/dmdhrumilmistry/fasthttpclient
```
- Without Rate Limit
```go
package main
import (
"log"
"github.com/dmdhrumilmistry/fasthttpclient/client"
"github.com/valyala/fasthttp"
)
func main() {
// Create a new FHClient without any rate limit
fhc := client.NewFHClient(&fasthttp.Client{})
queryParams := map[string]string{
"queryParam1": "value1",
"queryParam2": "value2",
}
// use fhc to make a GET request
resp, err := client.Get(fhc, "https://example.com", queryParams, nil)
if err != nil {
log.Fatalln(err)
}
log.Println(resp.StatusCode)
log.Println(resp.Headers)
log.Println(string(resp.Body))
log.Println(resp.CurlCommand)
}
```
- Using Rate Limit 100 requests/1sec
```go
package main
import (
"log"
"github.com/dmdhrumilmistry/fasthttpclient/client"
"github.com/valyala/fasthttp"
)
func main() {
// Create a new RateLimitedClient with 100 requests per second
rlclient := client.NewRateLimitedClient(100, 1, &fasthttp.Client{})
queryParams := map[string]string{
"queryParam1": "value1",
"queryParam2": "value2",
}
headers := map[string]string{
"Content-Type": "application/json",
}
body := []byte(`{"key": "value"}`)
resp, err := client.Post(rlclient, "https://example.com", queryParams, headers, body)
if err != nil {
log.Fatalln(err)
}
log.Println(resp.StatusCode)
log.Println(resp.Headers)
log.Println(string(resp.Body))
log.Println(resp.CurlCommand)
}
```
- View all [examples](./examples/)