Call a REST API in Go and automatically decode the JSON response into a struct with minimal setup code.
Add automatic retry with configurable backoff to HTTP requests without rewriting existing code.
Debug HTTP issues during development by printing full request and response details with a single setting, then turn it off for production.
Upload or download files with progress callbacks in a Go app without manual byte stream handling.
req is a Go library for making HTTP requests. Go includes a built-in HTTP client in its standard library, but it requires more setup code than many developers want to write for routine tasks like decoding JSON responses, adding authentication headers, retrying failed requests, or inspecting what was actually sent and received. req wraps that standard client with a cleaner interface that chains settings together and handles many common cases automatically. The library automatically detects whether a server supports HTTP/2 or HTTP/3 and uses the best version available, though you can force a specific version if needed. It decodes response bodies into Go structs based on the content type without requiring extra parsing code, and it similarly encodes request bodies from structs automatically. Character encoding detection handles servers that return text in non-UTF-8 encodings, converting to UTF-8 so the application receives consistent text. For debugging, the library can print the full contents of every request and response, including headers and body, to help identify problems during development. A performance tracing mode shows timing breakdowns for each phase of a request, such as connection time and time to first byte. These tools can be turned on globally during development and turned off for production with a single setting. Other included features are automatic retry with configurable backoff, file upload and download with progress callbacks, HTTP Basic Auth, Bearer token auth, Digest auth, and middleware hooks that run before or after each request. The library is also designed so its transport layer can replace the transport in an existing standard-library HTTP client, which makes it possible to add these features to code that was already written without rewriting it from scratch.
← imroc on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.