explaingit

imroc/req

4,794GoAudience · developerComplexity · 2/5Setup · easy

TLDR

A Go HTTP client library that wraps the standard library with a cleaner API, handling JSON encoding and decoding, retries, auth, file uploads, and HTTP/2 and HTTP/3 automatically with far less boilerplate.

Mindmap

mindmap
  root((req))
    What it does
      Cleaner HTTP client API
      Auto JSON encode and decode
      HTTP/2 and HTTP/3 support
    Features
      Retry with backoff
      File upload and download
      Auth helpers
    Auth Options
      Basic Auth
      Bearer token
      Digest Auth
    Debugging
      Full request logging
      Performance tracing
      Toggle for production
    Integration
      Drop-in transport swap
      Middleware hooks
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Call a REST API in Go and automatically decode the JSON response into a struct with minimal setup code.

USE CASE 2

Add automatic retry with configurable backoff to HTTP requests without rewriting existing code.

USE CASE 3

Debug HTTP issues during development by printing full request and response details with a single setting, then turn it off for production.

USE CASE 4

Upload or download files with progress callbacks in a Go app without manual byte stream handling.

Tech stack

GoHTTP/2HTTP/3JSONREST APIs

Getting it running

Difficulty · easy Time to first run · 5min
No license information is mentioned in the explanation.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me how to use the req library in Go to call a REST API, decode the JSON response into a struct, and retry automatically on failure.
Prompt 2
How do I add a Bearer token to every request made with req in Go, without setting the header manually each time?
Prompt 3
I want to enable full request and response debug logging in req during development, how do I turn it on and off with one setting?
Prompt 4
How do I upload a file with a progress callback using req in Go?
Prompt 5
How do I swap req's transport into an existing standard-library http.Client so I get retry and debug features without rewriting my code?
Open on GitHub → Explain another repo

← imroc on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.