Skip to content

fasthttpclient makes it easy for devs to make HTTP calls.

License

Notifications You must be signed in to change notification settings

dmdhrumilmistry/fasthttpclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastHttpClient

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

    go get github.com/dmdhrumilmistry/fasthttpclient
  • Without Rate Limit

    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

    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

About

fasthttpclient makes it easy for devs to make HTTP calls.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published