Coder Social home page Coder Social logo

clink's Introduction

test coverage goreportcard gopkg license

Clink: A Configurable HTTP Client for Go

Clink is a highly configurable HTTP client for Go, designed for ease of use, extendability, and robustness. It supports various features like automatic retries and request rate limiting, making it ideal for both simple and advanced HTTP requests.

Features

  • Flexible Request Options: Easily configure headers, URLs, and authentication.
  • Retry Mechanism: Automatic retries with configurable policies.
  • Rate Limiting: Client-side rate limiting to avoid server-side limits.

Installation

To use Clink in your Go project, install it using go get:

go get -u github.com/davesavic/clink

Usage

Here is a basic example of how to use Clink:

package main

import (
	"fmt"
	"github.com/davesavic/clink"
	"net/http"
)

func main() {
	// Create a new client with default options.
	client := clink.NewClient()

	// Create a new request with default options.
	req, err := http.NewRequest(http.MethodGet, "https://httpbin.org/anything", nil)

	// Send the request and get the response.
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}

	// Hydrate the response body into a map.
	var target map[string]any
	err = clink.ResponseToJson(resp, &target)

	// Print the target map.
	fmt.Println(target)
}

HTTP Methods (HEAD, OPTIONS, GET, HEAD, POST, PATCH, DELETE) are also supported

package main

import (
	"github.com/davesavic/clink"
	"encoding/json"
)

func main() {
    client := clink.NewClient()
    resp, err := client.Get("https://httpbin.org/get")
    // ....
    payload, err := json.Marshal(map[string]string{"username": "yumi"})
    resp, err := client.Post("https://httpbin.org/post", payload)
}

Examples

For more examples, see the examples directory.

Contributing

Contributions to Clink are welcome! If you find a bug, have a feature request, or want to contribute code, please open an issue or submit a pull request.

clink's People

Contributors

davesavic avatar josuebrunel avatar

Stargazers

Igor Shmel avatar  avatar Francis Miyoba avatar choppa_choppa avatar Simon Shi avatar  avatar Oleksandr Nosov avatar  avatar Raúl Pleitez avatar retr0 avatar Abdulhafiz KAŞGARLI avatar  avatar xuegang.leng avatar canberk avatar acid avatar 虫子樱桃 avatar Braulio Aguilar avatar Sarmat Kasaev avatar Evgeny Markov avatar NiktoX2 avatar ringsaturn avatar Antares avatar fan-tastic-z avatar  avatar Philipp Kraus avatar smallnest avatar Artem Dubinin avatar Kud1acz avatar  avatar Alexander Zaraysky avatar Samy Dougui avatar  avatar Oleksandr Sadovyi avatar Andrey Pochatkov avatar  avatar DavidPham avatar Alex Bhattarai avatar Ufuktan Yıldırım avatar Peter Vreča avatar Florian Flatscher avatar Thomas Laurenson avatar Auuu Nya avatar

Watchers

 avatar

clink's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.