Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 14 days 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 (7 months ago)
- Default Branch: main
- Last Pushed: 2024-12-10T06:39:52.000Z (19 days ago)
- Last Synced: 2024-12-14T18:53:57.997Z (14 days ago)
- Topics: fasthttp, fasthttpclient, go, golang
- Language: Go
- Homepage:
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastHttpClient
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](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 mainimport (
"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 mainimport (
"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/)