https://github.com/hueristiq/hq-go-http
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.
https://github.com/hueristiq/hq-go-http
go golang golang-package http-client http-headers http-methods http-status http-status-codes
Last synced: about 1 year ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/hueristiq/hq-go-http
- Owner: hueristiq
- License: mit
- Created: 2024-10-05T21:49:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-12T18:31:06.000Z (over 1 year ago)
- Last Synced: 2025-02-23T19:37:30.713Z (over 1 year ago)
- Topics: go, golang, golang-package, http-client, http-headers, http-methods, http-status, http-status-codes
- Language: Go
- Homepage: https://pkg.go.dev/github.com/hueristiq/hq-go-http
- Size: 121 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# hq-go-http
 [](https://goreportcard.com/report/github.com/hueristiq/hq-go-http) [](https://github.com/hueristiq/hq-go-http/blob/master/LICENSE)  [](https://github.com/hueristiq/hq-go-http/issues?q=is:issue+is:open) [](https://github.com/hueristiq/hq-go-http/issues?q=is:issue+is:closed) [](https://github.com/hueristiq/hq-go-http/blob/master/CONTRIBUTING.md)
`hq-go-http` is a [Go (Golang)](http://golang.org/) package for robust and flexible HTTP communication. It provides advanced features such as configurable retry policies, automatic fallback between HTTP/1.x and HTTP/2, and fluent request building with connection management.
## Resource
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [Licensing](#licensing)
## Features
- **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 package automatically falls back to HTTP/2.
- **Connection Management:** Automatically manages idle connections to prevent resource exhaustion, ensuring that connections are properly drained and closed when no longer needed.
- **Configurable Retry Logic:** Customize the maximum number of retries, set minimum/maximum wait times, and choose your backoff strategy (e.g., exponential backoff with jitter).
## Installation
To install `hq-go-http`, run:
```bash
go get -v -u github.com/hueristiq/hq-go-http
```
Make sure your Go environment is set up properly (Go 1.x or later is recommended).
## Usage
Here's a simple example demonstrating how to use `hq-go-http`:
```go
package main
import (
"log"
hqgohttp "github.com/hueristiq/hq-go-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.Get("https://example.com")
if err != nil {
log.Fatalf("Request failed: %v", err)
}
defer response.Body.Close()
// Handle response here
}
```
## Contributing
Contributions are welcome and encouraged! Feel free to submit [Pull Requests](https://github.com/hueristiq/hq-go-http/pulls) or report [Issues](https://github.com/hueristiq/hq-go-http/issues). For more details, check out the [contribution guidelines](https://github.com/hueristiq/hq-go-http/blob/master/CONTRIBUTING.md).
A big thank you to all the [contributors](https://github.com/hueristiq/hq-go-http/graphs/contributors) for your ongoing support!

## Licensing
This package is licensed under the [MIT license](https://opensource.org/license/mit). 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](https://github.com/hueristiq/hq-go-http/blob/master/LICENSE).