https://github.com/etaaa/httpez
A lightweight and modern wrapper around net/http designed for simplicity.
https://github.com/etaaa/httpez
Last synced: 10 months ago
JSON representation
A lightweight and modern wrapper around net/http designed for simplicity.
- Host: GitHub
- URL: https://github.com/etaaa/httpez
- Owner: etaaa
- License: mit
- Created: 2025-09-05T18:06:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-05T18:49:10.000Z (10 months ago)
- Last Synced: 2025-09-05T20:45:25.280Z (10 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpez
httpez is a lightweight, user-friendly wrapper around Go’s standard net/http client. It simplifies HTTP interactions while remaining fully compatible with the standard library.
## Features
- Drop-in replacement for `http.Client`
- Global headers applied to all requests.
- Extensible middleware system for request and response logic.
- Convenient `*AndReadBody` helpers for quickly fetching response bodies.
- Fluent API for building clients and requests
## Installation
```bash
go get github.com/etaaa/httpez
```
## Usage
Here is a basic example demonstrating how to create a client and make a simple request with headers.
```golang
package main
import (
"fmt"
"log"
"github.com/etaaa/httpez"
)
func main() {
// Create a new client.
client := httpez.NewClient()
// Set custom headers for all requests made with this client.
client.Headers().
Set("Accept", "application/json").
Set("User-Agent", "httpez-example")
// Performs a GET request to the specified URL, reads and returns
// the entire response body, and automatically closes the response body.
body, _, err := client.GetAndReadBody("https://httpbin.org/headers")
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}
```
For more detailed examples, including how to use middleware, please see the `examples` folder.
## Contributing
Contributions are welcome! Please open issues or submit pull requests for bugs, feature requests, or improvements.