New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

go.source.hueristiq.com/http

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

go.source.hueristiq.com/http

v0.0.0-20250212183008-cda247576f0e
Go
Version published
Created
Source

hq-go-http

made with go go report card license maintenance open issues closed issues contribution

hq-go-http is a Go (Golang) package for robust and flexible HTTP communication. It offers advanced features such as configurable retry policies, fallback to HTTP/2, custom hooks for request/response/error handling, and fluent request building with connection management.

Resource

Features

  • Configurable Retry Logic: Customize retry policies and backoff strategies to handle transient network errors gracefully.
  • HTTP/1.x and HTTP/2 Support: The client maintains both HTTP/1.x and HTTP/2 clients. If the HTTP/1.x client encounters a specific transport error, the library automatically falls back to HTTP/2.
  • Custom Hook Functions: Attach custom functions that are invoked:
    • Before a request is sent (OnRequest)
    • After a response is received (OnResponse)
    • When all retry attempts are exhausted (OnError)
  • Connection Management: Automatically drain and close idle connections to prevent resource exhaustion in long-running applications.
  • Fluent Request Building: Use the provided RequestBuilder to construct and send HTTP requests in a clear and concise manner.
  • Custom Client Configuration: Easily configure timeouts, retry parameters, backoff strategies, and connection management options through ClientConfiguration.

Installation

To install the package, run the following command in your terminal:

go get -v -u go.source.hueristiq.com/http

This command will download and install the hq-go-http package into your Go workspace, making it available for use in your projects.

Usage

Here's a simple example demonstrating how to use hq-go-http:

package main

import (
	"log"

	hqgohttp "go.source.hueristiq.com/http"
)

func main() {
	client := hqgohttp.NewClient(&hqgohttp.ClientConfiguration{
		RetryMax:     3,              // Max number of retries
		Timeout:      10 * time.Second, // Request timeout
		RetryWaitMin: 1 * time.Second, // Minimum wait between retries
		RetryWaitMax: 5 * time.Second, // Maximum wait between retries
	})

	response, err := client.Request().Method("GET").URL("https://example.com").Send()
	if err != nil {
		log.Fatalf("Request failed: %v", err)
	}

	defer response.Body.Close()
	// Handle response here
}

Contributing

Feel free to submit Pull Requests or report Issues. For more details, check out the contribution guidelines.

Huge thanks to the contributors thus far!

contributors

Licensing

This package is licensed under the MIT license. You are free to use, modify, and distribute it, as long as you follow the terms of the license. You can find the full license text in the repository - Full MIT license text.

FAQs

Package last updated on 12 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts