{"id":35198883,"url":"https://github.com/goforj/httpx","last_synced_at":"2026-01-13T21:19:12.584Z","repository":{"id":329837816,"uuid":"1120287384","full_name":"goforj/httpx","owner":"goforj","description":"A modern, generics-first fluent HTTP client for Go - built on req, designed for ergonomic, type-safe APIs with powerful defaults and escape hatches.","archived":false,"fork":false,"pushed_at":"2025-12-30T05:49:39.000Z","size":3062,"stargazers_count":77,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T04:19:38.913Z","etag":null,"topics":["api-client","developer-tools","generics","go","go-library","golang","http","http-client","networking","req","rest","typed"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goforj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-20T22:03:20.000Z","updated_at":"2026-01-01T00:44:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/goforj/httpx","commit_stats":null,"previous_names":["goforj/httpx"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/goforj/httpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goforj%2Fhttpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goforj%2Fhttpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goforj%2Fhttpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goforj%2Fhttpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goforj","download_url":"https://codeload.github.com/goforj/httpx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goforj%2Fhttpx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","developer-tools","generics","go","go-library","golang","http","http-client","networking","req","rest","typed"],"created_at":"2025-12-29T09:28:31.447Z","updated_at":"2026-01-13T21:19:12.571Z","avatar_url":"https://github.com/goforj.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/images/logo.png\" width=\"600\" alt=\"httpx Logo\"\u003e\n\u003c/p\u003e\n\nA generics-first HTTP client wrapper for Go, built on top of the amazing `github.com/imroc/req/v3` library.\nIt keeps req's power and escape hatches, while making the 90% use case feel effortless.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pkg.go.dev/github.com/goforj/httpx\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/goforj/httpx.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n    \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/goforj/httpx/actions\"\u003e\u003cimg src=\"https://github.com/goforj/httpx/actions/workflows/test.yml/badge.svg\" alt=\"Go Test\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://golang.org\"\u003e\u003cimg src=\"https://img.shields.io/badge/go-1.18+-blue?logo=go\" alt=\"Go version\"\u003e\u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/goforj/httpx?label=version\u0026sort=semver\" alt=\"Latest tag\"\u003e\n    \u003ca href=\"https://goreportcard.com/report/github.com/goforj/httpx\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/goforj/httpx\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/goforj/httpx\" \u003e\u003cimg src=\"https://codecov.io/gh/goforj/httpx/graph/badge.svg?token=R5O7LYAD4B\"/\u003e\u003c/a\u003e\n\u003c!-- test-count:embed:start --\u003e\n    \u003cimg src=\"https://img.shields.io/badge/tests-203-brightgreen\" alt=\"Tests\"\u003e\n\u003c!-- test-count:embed:end --\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/images/goforj_httpx_example_1.png\" alt=\"httpx Logo\"\u003e\n\u003c/p\u003e\n\n## What is httpx?\n\n**httpx** is a modern, ergonomic HTTP client for Go.\n\nIt builds on top of the amazing [`req`](https://github.com/imroc/req) library, preserving its flexibility while dramatically reducing boilerplate for common use cases. You get clean defaults, strong typing, and an API designed to stay out of your way.\n\nThink of it as *the 90% solution* - powerful enough for real-world systems, without sacrificing clarity or control.\n\n## Quick Start\n\n```go\ntype Response struct {\n    URL string `json:\"url\"`\n}\n\nc := httpx.New(\n    httpx.BaseURL(\"https://httpbin.org\"),\n\t// ...other options as needed\n)\n\n// httpx.Get[T](client, url, options...)\nres, err := httpx.Get[Response](c, \"/get\")\nif err != nil {\n    panic(err) // handle error appropriately\n}\n\nfmt.Println(res.URL)\n````\n\n## Design Principles\n\n* **Simple by default** - minimal configuration for common cases\n* **Composable** - everything is opt-in and chainable\n* **Predictable** - no hidden behavior or magic\n* **Typed** - first-class generics with zero reflection\n* **Escape hatches included** - full access to `req` when needed\n\n## When to Use httpx\n\nUse httpx when you want:\n\n* A clean, expressive HTTP client without boilerplate\n* Strong typing without fighting the type system\n* Easy composition of headers, params, and behavior\n* A smooth path from simple requests to advanced control\n\nIf you’re comfortable with `net/http` or `req`, httpx will feel immediately familiar - just faster to write and easier to read.\n\n## Installation\n\n```bash\ngo get github.com/goforj/httpx\n```\n\n## Debugging and Tracing\n\n- `HTTP_TRACE=1` enables request/response dumps for all requests.\n- `httpx.EnableDump()` enables dump for a single request.\n- `httpx.DumpEachRequest()` enables per-request dumps on a client.\n\n## Documentation\n\nThe full API reference below is generated directly from source and always reflects the current codebase.\n\nAll runnable examples live in [`./examples`](./examples) and are generated from doc comments.\n\nThey are compiled and executed in CI to ensure the documentation stays accurate and up to date.\n\n## Contributing\n\n- Run `go run ./docs/examplegen` after updating doc examples.\n- Run `go run ./docs/readme/main.go` to refresh the API index and test count.\n- Run `go test ./...`.\n\n## v2 Status\n\nhttpx v1 has been tagged and is now frozen. The `main` branch is v2, which includes intentional breaking changes to improve API clarity and ergonomics (for example, request helpers return `(T, error)`).\n\n\u003c!-- api:embed:start --\u003e\n\n## API Index\n\n| Group | Functions |\n|------:|:-----------|\n| **Auth** | [Auth](#auth) [Basic](#basic) [Bearer](#bearer) |\n| **Browser Profiles** | [AsChrome](#aschrome) [AsFirefox](#asfirefox) [AsMobile](#asmobile) [AsSafari](#assafari) |\n| **Client** | [Default](#default) [New](#new) [Raw](#raw) [Req](#req) |\n| **Client Options** | [BaseURL](#baseurl) [CookieJar](#cookiejar) [ErrorMapper](#errormapper) [Middleware](#middleware) [Proxy](#proxy) [ProxyFunc](#proxyfunc) [Redirect](#redirect) [Transport](#transport) |\n| **Debugging** | [Dump](#dump) [DumpAll](#dumpall) [DumpEachRequest](#dumpeachrequest) [DumpEachRequestTo](#dumpeachrequestto) [DumpTo](#dumpto) [DumpToFile](#dumptofile) [EnableDump](#enabledump) [Trace](#trace) [TraceAll](#traceall) |\n| **Download Options** | [OutputFile](#outputfile) |\n| **Errors** | [Error](#error) |\n| **Request Composition** | [Body](#body) [Form](#form) [Header](#header) [Headers](#headers) [JSON](#json) [Path](#path) [Paths](#paths) [Queries](#queries) [Query](#query) [UserAgent](#useragent) |\n| **Request Control** | [Before](#before) [Timeout](#timeout) |\n| **Requests** | [Delete](#delete) [Do](#do) [Get](#get) [Head](#head) [Options](#options) [Patch](#patch) [Post](#post) [Put](#put) |\n| **Requests (Context)** | [DeleteCtx](#deletectx) [GetCtx](#getctx) [HeadCtx](#headctx) [OptionsCtx](#optionsctx) [PatchCtx](#patchctx) [PostCtx](#postctx) [PutCtx](#putctx) |\n| **Retry** | [RetryBackoff](#retrybackoff) [RetryCondition](#retrycondition) [RetryCount](#retrycount) [RetryFixedInterval](#retryfixedinterval) [RetryHook](#retryhook) [RetryInterval](#retryinterval) |\n| **Retry (Client)** | [Retry](#retry) |\n| **Upload Options** | [File](#file) [FileBytes](#filebytes) [FileReader](#filereader) [Files](#files) [UploadCallback](#uploadcallback) [UploadCallbackWithInterval](#uploadcallbackwithinterval) [UploadProgress](#uploadprogress) |\n| **Advanced** | [TLSFingerprint](#tlsfingerprint) [TLSFingerprintAndroid](#tlsfingerprintandroid) [TLSFingerprintChrome](#tlsfingerprintchrome) [TLSFingerprintEdge](#tlsfingerprintedge) [TLSFingerprintFirefox](#tlsfingerprintfirefox) [TLSFingerprintIOS](#tlsfingerprintios) [TLSFingerprintRandomized](#tlsfingerprintrandomized) [TLSFingerprintSafari](#tlsfingerprintsafari) |\n\n\n## Auth\n\n### \u003ca id=\"auth\"\u003e\u003c/a\u003eAuth\n\nAuth sets the Authorization header using a scheme and token.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Auth(\"Token\", \"abc123\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Token abc123\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.Auth(\"Token\", \"abc123\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Token abc123\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"basic\"\u003e\u003c/a\u003eBasic\n\nBasic sets HTTP basic authentication headers.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Basic(\"user\", \"pass\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Basic dXNlcjpwYXNz\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.Basic(\"user\", \"pass\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Basic dXNlcjpwYXNz\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"bearer\"\u003e\u003c/a\u003eBearer\n\nBearer sets the Authorization header with a bearer token.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Bearer(\"token\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Bearer token\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.Bearer(\"token\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Authorization =\u003e \"Bearer token\" #string\n//   }\n// }\n```\n\n## Browser Profiles\n\n### \u003ca id=\"aschrome\"\u003e\u003c/a\u003eAsChrome\n\nAsChrome applies the Chrome browser profile (headers including User-Agent, TLS, and HTTP/2 behavior).\n\n```go\n_ = httpx.New(httpx.AsChrome())\n```\n\n### \u003ca id=\"asfirefox\"\u003e\u003c/a\u003eAsFirefox\n\nAsFirefox applies the Firefox browser profile (headers including User-Agent, TLS, and HTTP/2 behavior).\n\n```go\nc := httpx.New(httpx.AsFirefox())\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     User-Agent =\u003e \"\u003cuser-agent\u003e\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"asmobile\"\u003e\u003c/a\u003eAsMobile\n\nAsMobile applies a mobile Chrome-like profile (headers including User-Agent, TLS, and HTTP/2 behavior).\n\n```go\n_ = httpx.New(httpx.AsMobile())\n```\n\n### \u003ca id=\"assafari\"\u003e\u003c/a\u003eAsSafari\n\nAsSafari applies the Safari browser profile (headers including User-Agent, TLS, and HTTP/2 behavior).\n\n```go\n_ = httpx.New(httpx.AsSafari())\n```\n\n## Client\n\n### \u003ca id=\"default\"\u003e\u003c/a\u003eDefault\n\nDefault returns the shared default client.\n\n### \u003ca id=\"new\"\u003e\u003c/a\u003eNew\n\nNew creates a client with opinionated defaults and optional overrides.\n\n```go\nvar buf bytes.Buffer\n_ = httpx.New(httpx.\n\tBaseURL(\"https://httpbin.org\").\n\tTimeout(5*time.Second).\n\tHeader(\"X-Trace\", \"1\").\n\tHeader(\"Accept\", \"application/json\").\n\tTransport(http.RoundTripper(http.DefaultTransport)).\n\tMiddleware(func(_ *req.Client, r *req.Request) error {\n\t\tr.SetHeader(\"X-Middleware\", \"1\")\n\t\treturn nil\n\t}).\n\tErrorMapper(func(resp *req.Response) error {\n\t\treturn fmt.Errorf(\"status %d\", resp.StatusCode)\n\t}).\n\tDumpAll().\n\tDumpEachRequest().\n\tDumpEachRequestTo(\u0026buf).\n\tRetry(func(rc *req.Client) {\n\t\trc.SetCommonRetryCount(2)\n\t}).\n\tRetryCount(2).\n\tRetryFixedInterval(200*time.Millisecond).\n\tRetryBackoff(100*time.Millisecond, 2*time.Second).\n\tRetryInterval(func(_ *req.Response, attempt int) time.Duration {\n\t\treturn time.Duration(attempt) * 100 * time.Millisecond\n\t}).\n\tRetryCondition(func(resp *req.Response, _ error) bool {\n\t\treturn resp != nil \u0026\u0026 resp.StatusCode == 503\n\t}).\n\tRetryHook(func(_ *req.Response, _ error) {}),\n)\n```\n\n### \u003ca id=\"raw\"\u003e\u003c/a\u003eRaw\n\nRaw returns the underlying req client for chaining raw requests.\n\n### \u003ca id=\"req\"\u003e\u003c/a\u003eReq\n\nReq returns the underlying req client for advanced usage.\n\n## Client Options\n\n### \u003ca id=\"baseurl\"\u003e\u003c/a\u003eBaseURL\n\nBaseURL sets a base URL on the client.\n\n```go\nc := httpx.New(httpx.BaseURL(\"https://httpbin.org\"))\nres, _ := httpx.Get[map[string]any](c, \"/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"cookiejar\"\u003e\u003c/a\u003eCookieJar\n\nCookieJar sets the cookie jar for the client.\n\n```go\njar, _ := cookiejar.New(nil)\nu, _ := url.Parse(\"https://httpbin.org\")\njar.SetCookies(u, []*http.Cookie{\n\t{Name: \"session\", Value: \"abc123\"},\n})\nc := httpx.New(httpx.CookieJar(jar))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/cookies\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   cookies =\u003e #map[string]interface {} {\n//     session =\u003e \"abc123\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"errormapper\"\u003e\u003c/a\u003eErrorMapper\n\nErrorMapper sets a custom error mapper for non-2xx responses.\n\n```go\nc := httpx.New(httpx.ErrorMapper(func(resp *req.Response) error {\n\treturn fmt.Errorf(\"status %d\", resp.StatusCode)\n}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/status/500\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n### \u003ca id=\"middleware\"\u003e\u003c/a\u003eMiddleware\n\nMiddleware adds request middleware to the client.\n\n```go\nc := httpx.New(httpx.Middleware(func(_ *req.Client, r *req.Request) error {\n\tr.SetHeader(\"X-Trace\", \"1\")\n\treturn nil\n}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"proxy\"\u003e\u003c/a\u003eProxy\n\nProxy sets a proxy URL for the client.\n\n```go\nc := httpx.New(httpx.Proxy(\"http://localhost:8080\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/get\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n### \u003ca id=\"proxyfunc\"\u003e\u003c/a\u003eProxyFunc\n\nProxyFunc sets a proxy function for the client.\n\n```go\nc := httpx.New(httpx.ProxyFunc(http.ProxyFromEnvironment))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"redirect\"\u003e\u003c/a\u003eRedirect\n\nRedirect sets the redirect policy for the client.\n\n```go\nc := httpx.New(httpx.Redirect(req.NoRedirectPolicy()))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/redirect/1\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n### \u003ca id=\"transport\"\u003e\u003c/a\u003eTransport\n\nTransport wraps the underlying transport with a custom RoundTripper.\n\n```go\nc := httpx.New(httpx.Transport(http.RoundTripper(http.DefaultTransport)))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n## Debugging\n\n### \u003ca id=\"dump\"\u003e\u003c/a\u003eDump\n\nDump prints values using the bundled godump formatter.\n\n```go\nres, _ := httpx.Get[map[string]any](httpx.Default(), \"https://httpbin.org/uuid\")\nhttpx.Dump(res)\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"dumpall\"\u003e\u003c/a\u003eDumpAll\n\nDumpAll enables req's client-level dump output for all requests.\n\n```go\nc := httpx.New(httpx.DumpAll())\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"dumpeachrequest\"\u003e\u003c/a\u003eDumpEachRequest\n\nDumpEachRequest enables request-level dumps for each request on the client.\n\n```go\nc := httpx.New(httpx.DumpEachRequest())\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"dumpeachrequestto\"\u003e\u003c/a\u003eDumpEachRequestTo\n\nDumpEachRequestTo enables request-level dumps for each request and writes them to the provided output.\n\n```go\nvar buf bytes.Buffer\nc := httpx.New(httpx.DumpEachRequestTo(\u0026buf))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n_ = buf.String()\n```\n\n### \u003ca id=\"dumpto\"\u003e\u003c/a\u003eDumpTo\n\nDumpTo enables req's request-level dump output to a writer.\n\n```go\nvar buf bytes.Buffer\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.DumpTo(\u0026buf))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"dumptofile\"\u003e\u003c/a\u003eDumpToFile\n\nDumpToFile enables req's request-level dump output to a file path.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.DumpToFile(\"httpx.dump\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"enabledump\"\u003e\u003c/a\u003eEnableDump\n\nEnableDump enables req's request-level dump output.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.EnableDump())\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"trace\"\u003e\u003c/a\u003eTrace\n\nTrace enables req's request-level trace output.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.Trace())\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"traceall\"\u003e\u003c/a\u003eTraceAll\n\nTraceAll enables req's client-level trace output for all requests.\n\n```go\nc := httpx.New(httpx.TraceAll())\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n## Download Options\n\n### \u003ca id=\"outputfile\"\u003e\u003c/a\u003eOutputFile\n\nOutputFile streams the response body to a file path.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/bytes/1024\", httpx.OutputFile(\"/tmp/file.bin\"))\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n## Errors\n\n### \u003ca id=\"error\"\u003e\u003c/a\u003eError\n\nError returns a short, human-friendly summary of the HTTP error.\n\n```go\ntype User struct {\n\tName string `json:\"name\"`\n}\n\nc := httpx.New()\nres, err := httpx.Get[map[string]any](c, \"https://httpbin.org/status/404\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\nvar httpErr *httpx.HTTPError\nif errors.As(err, \u0026httpErr) {\n\t_ = httpErr.StatusCode\n}\n```\n\n## Request Composition\n\n### \u003ca id=\"body\"\u003e\u003c/a\u003eBody\n\nBody sets the request body and infers JSON for structs and maps.\n\n```go\ntype Payload struct {\n\tName string `json:\"name\"`\n}\n\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.Body(Payload{Name: \"Ana\"}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   json =\u003e #map[string]interface {} {\n//     name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"form\"\u003e\u003c/a\u003eForm\n\nForm sets form data for the request.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.Form(map[string]string{\n\t\"name\": \"alice\",\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   form =\u003e #map[string]interface {} {\n//     name =\u003e \"alice\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"header\"\u003e\u003c/a\u003eHeader\n\nHeader sets a header on a request or client.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Header(\"X-Trace\", \"1\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.Header(\"X-Trace\", \"1\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"headers\"\u003e\u003c/a\u003eHeaders\n\nHeaders sets multiple headers on a request or client.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Headers(map[string]string{\n\t\"X-Trace\": \"1\",\n\t\"Accept\":  \"application/json\",\n}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Accept =\u003e \"application/json\" #string\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.Headers(map[string]string{\n\t\"X-Trace\": \"1\",\n\t\"Accept\":  \"application/json\",\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     Accept =\u003e \"application/json\" #string\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"json\"\u003e\u003c/a\u003eJSON\n\nJSON forces JSON encoding for the request body (even when inference might choose differently).\n\n```go\ntype Payload struct {\n\tName string `json:\"name\"`\n}\n\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.JSON(Payload{Name: \"Ana\"}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   json =\u003e #map[string]interface {} {\n//     name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"path\"\u003e\u003c/a\u003ePath\n\nPath sets a path parameter by name.\n\n```go\ntype User struct {\n\tName string `json:\"name\"`\n}\n\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/anything/{id}\", httpx.Path(\"id\", 42))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   url =\u003e \"https://httpbin.org/anything/42\" #string\n// }\n```\n\n### \u003ca id=\"paths\"\u003e\u003c/a\u003ePaths\n\nPaths sets multiple path parameters from a map.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/anything/{org}/users/{id}\", httpx.Paths(map[string]any{\n\t\"org\": \"goforj\",\n\t\"id\":  7,\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   url =\u003e \"https://httpbin.org/anything/goforj/users/7\" #string\n// }\n```\n\n### \u003ca id=\"queries\"\u003e\u003c/a\u003eQueries\n\nQueries sets query parameters from a map.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/get\", httpx.Queries(map[string]string{\n\t\"q\":  \"search\",\n\t\"ok\": \"1\",\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   args =\u003e #map[string]interface {} {\n//     ok =\u003e \"1\" #string\n//     q =\u003e \"search\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"query\"\u003e\u003c/a\u003eQuery\n\nQuery adds query parameters as key/value pairs.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/get\", httpx.Query(\"q\", \"search\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   args =\u003e #map[string]interface {} {\n//     q =\u003e \"search\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"useragent\"\u003e\u003c/a\u003eUserAgent\n\nUserAgent sets the User-Agent header on a request or client.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.UserAgent(\"my-app/1.0\"))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/headers\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     User-Agent =\u003e \"my-app/1.0\" #string\n//   }\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/headers\", httpx.UserAgent(\"my-app/1.0\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     User-Agent =\u003e \"my-app/1.0\" #string\n//   }\n// }\n```\n\n## Request Control\n\n### \u003ca id=\"before\"\u003e\u003c/a\u003eBefore\n\nBefore runs a hook before the request is sent.\n\n```go\nc := httpx.New()\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/get\", httpx.Before(func(r *req.Request) {\n\tr.EnableDump()\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   url =\u003e \"https://httpbin.org/get\" #string\n// }\n```\n\n### \u003ca id=\"timeout\"\u003e\u003c/a\u003eTimeout\n\nTimeout sets a per-request timeout using context cancellation.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.Timeout(2 * time.Second))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/delay/2\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/delay/2\", httpx.Timeout(2*time.Second))\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n## Requests\n\n### \u003ca id=\"delete\"\u003e\u003c/a\u003eDelete\n\nDelete issues a DELETE request using the provided client.\n\n```go\ntype DeleteResponse struct {\n\tURL string `json:\"url\"`\n}\n\nc := httpx.New()\nres, err := httpx.Delete[DeleteResponse](c, \"https://httpbin.org/delete\")\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps DeleteResponse\n// #DeleteResponse {\n//   URL =\u003e \"https://httpbin.org/delete\" #string\n// }\n```\n\n### \u003ca id=\"do\"\u003e\u003c/a\u003eDo\n\nDo executes a pre-configured req request and returns the decoded body and response.\nThis is the low-level escape hatch when you need full req control.\n\n```go\nr := req.C().R().SetHeader(\"X-Trace\", \"1\")\nr.SetURL(\"https://httpbin.org/headers\")\nr.Method = http.MethodGet\n\nres, rawResp, err := httpx.Do[map[string]any](r)\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   headers =\u003e #map[string]interface {} {\n//     X-Trace =\u003e \"1\" #string\n//   }\n// }\nprintln(rawResp.StatusCode)\n```\n\n### \u003ca id=\"get\"\u003e\u003c/a\u003eGet\n\nGet issues a GET request using the provided client.\n\n_Example: bind to a struct_\n\n```go\ntype GetResponse struct {\n\tURL string `json:\"url\"`\n}\n\nc := httpx.New()\nres, _ := httpx.Get[GetResponse](c, \"https://httpbin.org/get\")\nhttpx.Dump(res)\n// #GetResponse {\n//   URL =\u003e \"https://httpbin.org/get\" #string\n// }\n```\n\n_Example: bind to a string body_\n\n```go\nresString, _ := httpx.Get[string](c, \"https://httpbin.org/uuid\")\nprintln(resString) // dumps string\n// {\n//   \"uuid\": \"becbda6d-9950-4966-ae23-0369617ba065\"\n// }\n```\n\n### \u003ca id=\"head\"\u003e\u003c/a\u003eHead\n\nHead issues a HEAD request using the provided client.\n\n```go\nc := httpx.New()\n_, err := httpx.Head[string](c, \"https://httpbin.org/get\")\nif err != nil {\n\treturn\n}\n```\n\n### \u003ca id=\"options\"\u003e\u003c/a\u003eOptions\n\nOptions issues an OPTIONS request using the provided client.\n\n```go\nc := httpx.New()\n_, err := httpx.Options[string](c, \"https://httpbin.org/get\")\nif err != nil {\n\treturn\n}\n```\n\n### \u003ca id=\"patch\"\u003e\u003c/a\u003ePatch\n\nPatch issues a PATCH request using the provided client.\n\n```go\ntype UpdateUser struct {\n\tName string `json:\"name\"`\n}\ntype UpdateUserResponse struct {\n\tJSON UpdateUser `json:\"json\"`\n}\n\nc := httpx.New()\nres, err := httpx.Patch[UpdateUser, UpdateUserResponse](c, \"https://httpbin.org/patch\", UpdateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps UpdateUserResponse\n// #UpdateUserResponse {\n//   JSON =\u003e #UpdateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"post\"\u003e\u003c/a\u003ePost\n\nPost issues a POST request using the provided client.\n\n```go\ntype CreateUser struct {\n\tName string `json:\"name\"`\n}\ntype CreateUserResponse struct {\n\tJSON CreateUser `json:\"json\"`\n}\n\nc := httpx.New()\nres, err := httpx.Post[CreateUser, CreateUserResponse](c, \"https://httpbin.org/post\", CreateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps CreateUserResponse\n// #CreateUserResponse {\n//   JSON =\u003e #CreateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"put\"\u003e\u003c/a\u003ePut\n\nPut issues a PUT request using the provided client.\n\n```go\ntype UpdateUser struct {\n\tName string `json:\"name\"`\n}\ntype UpdateUserResponse struct {\n\tJSON UpdateUser `json:\"json\"`\n}\n\nc := httpx.New()\nres, err := httpx.Put[UpdateUser, UpdateUserResponse](c, \"https://httpbin.org/put\", UpdateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps UpdateUserResponse\n// #UpdateUserResponse {\n//   JSON =\u003e #UpdateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n## Requests (Context)\n\n### \u003ca id=\"deletectx\"\u003e\u003c/a\u003eDeleteCtx\n\nDeleteCtx issues a DELETE request using the provided client and context.\n\n```go\ntype DeleteResponse struct {\n\tURL string `json:\"url\"`\n}\n\nctx := context.Background()\nc := httpx.New()\nres, err := httpx.DeleteCtx[DeleteResponse](c, ctx, \"https://httpbin.org/delete\")\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps DeleteResponse\n// #DeleteResponse {\n//   URL =\u003e \"https://httpbin.org/delete\" #string\n// }\n```\n\n### \u003ca id=\"getctx\"\u003e\u003c/a\u003eGetCtx\n\nGetCtx issues a GET request using the provided client and context.\n\n```go\ntype GetResponse struct {\n\tURL string `json:\"url\"`\n}\n\nctx := context.Background()\nc := httpx.New()\nres, err := httpx.GetCtx[GetResponse](c, ctx, \"https://httpbin.org/get\")\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps GetResponse\n// #GetResponse {\n//   URL =\u003e \"https://httpbin.org/get\" #string\n// }\n```\n\n### \u003ca id=\"headctx\"\u003e\u003c/a\u003eHeadCtx\n\nHeadCtx issues a HEAD request using the provided client and context.\n\n```go\nctx := context.Background()\nc := httpx.New()\n_, err := httpx.HeadCtx[string](c, ctx, \"https://httpbin.org/get\")\nif err != nil {\n\treturn\n}\n```\n\n### \u003ca id=\"optionsctx\"\u003e\u003c/a\u003eOptionsCtx\n\nOptionsCtx issues an OPTIONS request using the provided client and context.\n\n```go\nctx := context.Background()\nc := httpx.New()\n_, err := httpx.OptionsCtx[string](c, ctx, \"https://httpbin.org/get\")\nif err != nil {\n\treturn\n}\n```\n\n### \u003ca id=\"patchctx\"\u003e\u003c/a\u003ePatchCtx\n\nPatchCtx issues a PATCH request using the provided client and context.\n\n```go\ntype UpdateUser struct {\n\tName string `json:\"name\"`\n}\ntype UpdateUserResponse struct {\n\tJSON UpdateUser `json:\"json\"`\n}\n\nctx := context.Background()\nc := httpx.New()\nres, err := httpx.PatchCtx[UpdateUser, UpdateUserResponse](c, ctx, \"https://httpbin.org/patch\", UpdateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps UpdateUserResponse\n// #UpdateUserResponse {\n//   JSON =\u003e #UpdateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"postctx\"\u003e\u003c/a\u003ePostCtx\n\nPostCtx issues a POST request using the provided client and context.\n\n```go\ntype CreateUser struct {\n\tName string `json:\"name\"`\n}\ntype CreateUserResponse struct {\n\tJSON CreateUser `json:\"json\"`\n}\n\nctx := context.Background()\nc := httpx.New()\nres, err := httpx.PostCtx[CreateUser, CreateUserResponse](c, ctx, \"https://httpbin.org/post\", CreateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps CreateUserResponse\n// #CreateUserResponse {\n//   JSON =\u003e #CreateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"putctx\"\u003e\u003c/a\u003ePutCtx\n\nPutCtx issues a PUT request using the provided client and context.\n\n```go\ntype UpdateUser struct {\n\tName string `json:\"name\"`\n}\ntype UpdateUserResponse struct {\n\tJSON UpdateUser `json:\"json\"`\n}\n\nctx := context.Background()\nc := httpx.New()\nres, err := httpx.PutCtx[UpdateUser, UpdateUserResponse](c, ctx, \"https://httpbin.org/put\", UpdateUser{Name: \"Ana\"})\nif err != nil {\n\treturn\n}\nhttpx.Dump(res) // dumps UpdateUserResponse\n// #UpdateUserResponse {\n//   JSON =\u003e #UpdateUser {\n//     Name =\u003e \"Ana\" #string\n//   }\n// }\n```\n\n## Retry\n\n### \u003ca id=\"retrybackoff\"\u003e\u003c/a\u003eRetryBackoff\n\nRetryBackoff sets a capped exponential backoff retry interval for a request.\nOverrides the req default interval (fixed 100ms) with jittered backoff.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryBackoff(100*time.Millisecond, 2*time.Second))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.RetryBackoff(100*time.Millisecond, 2*time.Second))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"retrycondition\"\u003e\u003c/a\u003eRetryCondition\n\nRetryCondition sets the retry condition for a request.\nOverrides the default behavior (retry only when a request error occurs).\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryCondition(func(resp *req.Response, _ error) bool {\n\treturn resp != nil \u0026\u0026 resp.StatusCode == 503\n}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/status/503\")\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/status/503\", httpx.RetryCondition(func(resp *req.Response, _ error) bool {\n\treturn resp != nil \u0026\u0026 resp.StatusCode == 503\n}))\nhttpx.Dump(res) // dumps map[string]any\n// map[string]interface {}(nil)\n```\n\n### \u003ca id=\"retrycount\"\u003e\u003c/a\u003eRetryCount\n\nRetryCount enables retry for a request and sets the maximum retry count.\nDefault behavior from req: retries are disabled (count = 0). When enabled,\nretries happen only on request errors unless RetryCondition is set, and the\ndefault interval is a fixed 100ms between attempts.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryCount(2))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.RetryCount(2))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"retryfixedinterval\"\u003e\u003c/a\u003eRetryFixedInterval\n\nRetryFixedInterval sets a fixed retry interval for a request.\nOverrides the req default interval (fixed 100ms).\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryFixedInterval(200 * time.Millisecond))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.RetryFixedInterval(200*time.Millisecond))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"retryhook\"\u003e\u003c/a\u003eRetryHook\n\nRetryHook registers a retry hook for a request.\nRuns before each retry attempt; no hooks are configured by default.\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryHook(func(_ *req.Response, _ error) {}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.RetryHook(func(_ *req.Response, _ error) {}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n### \u003ca id=\"retryinterval\"\u003e\u003c/a\u003eRetryInterval\n\nRetryInterval sets a custom retry interval function for a request.\nOverrides the req default interval (fixed 100ms).\n\n```go\n// Apply to all requests\nc := httpx.New(httpx.RetryInterval(func(_ *req.Response, attempt int) time.Duration {\n\treturn time.Duration(attempt) * 100 * time.Millisecond\n}))\nres, _ := httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\")\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n\n// Apply to a single request\nres, _ = httpx.Get[map[string]any](c, \"https://httpbin.org/uuid\", httpx.RetryInterval(func(_ *req.Response, attempt int) time.Duration {\n\treturn time.Duration(attempt) * 100 * time.Millisecond\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   uuid =\u003e \"\u003cuuid\u003e\" #string\n// }\n```\n\n## Retry (Client)\n\n### \u003ca id=\"retry\"\u003e\u003c/a\u003eRetry\n\nRetry applies a custom retry configuration to the client.\nDefaults remain in effect unless the callback modifies them.\n\n```go\n_ = httpx.New(httpx.Retry(func(rc *req.Client) {\n\trc.SetCommonRetryCount(2)\n}))\n```\n\n## Upload Options\n\n### \u003ca id=\"file\"\u003e\u003c/a\u003eFile\n\nFile attaches a file from disk as multipart form data.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.File(\"file\", \"/tmp/report.txt\"))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"hello\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"filebytes\"\u003e\u003c/a\u003eFileBytes\n\nFileBytes attaches a file from bytes as multipart form data.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.FileBytes(\"file\", \"report.txt\", []byte(\"hello\")))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"hello\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"filereader\"\u003e\u003c/a\u003eFileReader\n\nFileReader attaches a file from a reader as multipart form data.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.FileReader(\"file\", \"report.txt\", strings.NewReader(\"hello\")))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"hello\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"files\"\u003e\u003c/a\u003eFiles\n\nFiles attaches multiple files from disk as multipart form data.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil, httpx.Files(map[string]string{\n\t\"fileA\": \"/tmp/a.txt\",\n\t\"fileB\": \"/tmp/b.txt\",\n}))\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     fileA =\u003e \"hello\" #string\n//     fileB =\u003e \"world\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"uploadcallback\"\u003e\u003c/a\u003eUploadCallback\n\nUploadCallback registers a callback for upload progress.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil,\n\thttpx.File(\"file\", \"/tmp/report.bin\"),\n\thttpx.UploadCallback(func(info req.UploadInfo) {\n\t\tpercent := float64(info.UploadedSize) / float64(info.FileSize) * 100\n\t\tfmt.Printf(\"\\rprogress: %.1f%%\", percent)\n\t\tif info.FileSize \u003e 0 \u0026\u0026 info.UploadedSize \u003e= info.FileSize {\n\t\t\tfmt.Print(\"\\n\")\n\t\t}\n\t}),\n)\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"\u003cfile\u003e\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"uploadcallbackwithinterval\"\u003e\u003c/a\u003eUploadCallbackWithInterval\n\nUploadCallbackWithInterval registers a callback for upload progress with a minimum interval.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil,\n\thttpx.File(\"file\", \"/tmp/report.bin\"),\n\thttpx.UploadCallbackWithInterval(func(info req.UploadInfo) {\n\t\tpercent := float64(info.UploadedSize) / float64(info.FileSize) * 100\n\t\tfmt.Printf(\"\\rprogress: %.1f%% (%.0f bytes)\", percent, float64(info.UploadedSize))\n\t\tif info.FileSize \u003e 0 \u0026\u0026 info.UploadedSize \u003e= info.FileSize {\n\t\t\tfmt.Print(\"\\n\")\n\t\t}\n\t}, 200*time.Millisecond),\n)\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"\u003cfile\u003e\" #string\n//   }\n// }\n```\n\n### \u003ca id=\"uploadprogress\"\u003e\u003c/a\u003eUploadProgress\n\nUploadProgress enables a default progress spinner and bar for uploads.\n\n```go\nc := httpx.New()\nres, _ := httpx.Post[any, map[string]any](c, \"https://httpbin.org/post\", nil,\n\thttpx.File(\"file\", \"/tmp/report.bin\"),\n\thttpx.UploadProgress(),\n)\nhttpx.Dump(res) // dumps map[string]any\n// #map[string]interface {} {\n//   files =\u003e #map[string]interface {} {\n//     file =\u003e \"\u003cfile\u003e\" #string\n//   }\n// }\n```\n\n## Advanced\n\n### \u003ca id=\"tlsfingerprint\"\u003e\u003c/a\u003eTLSFingerprint\n\nTLSFingerprint applies a TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprint(httpx.TLSFingerprintChromeKind))\n```\n\n### \u003ca id=\"tlsfingerprintandroid\"\u003e\u003c/a\u003eTLSFingerprintAndroid\n\nTLSFingerprintAndroid applies the Android TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintAndroid())\n```\n\n### \u003ca id=\"tlsfingerprintchrome\"\u003e\u003c/a\u003eTLSFingerprintChrome\n\nTLSFingerprintChrome applies the Chrome TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintChrome())\n```\n\n### \u003ca id=\"tlsfingerprintedge\"\u003e\u003c/a\u003eTLSFingerprintEdge\n\nTLSFingerprintEdge applies the Edge TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintEdge())\n```\n\n### \u003ca id=\"tlsfingerprintfirefox\"\u003e\u003c/a\u003eTLSFingerprintFirefox\n\nTLSFingerprintFirefox applies the Firefox TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintFirefox())\n```\n\n### \u003ca id=\"tlsfingerprintios\"\u003e\u003c/a\u003eTLSFingerprintIOS\n\nTLSFingerprintIOS applies the iOS TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintIOS())\n```\n\n### \u003ca id=\"tlsfingerprintrandomized\"\u003e\u003c/a\u003eTLSFingerprintRandomized\n\nTLSFingerprintRandomized applies a randomized TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintRandomized())\n```\n\n### \u003ca id=\"tlsfingerprintsafari\"\u003e\u003c/a\u003eTLSFingerprintSafari\n\nTLSFingerprintSafari applies the Safari TLS fingerprint preset.\n\n```go\n_ = httpx.New(httpx.TLSFingerprintSafari())\n```\n\u003c!-- api:embed:end --\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoforj%2Fhttpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoforj%2Fhttpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoforj%2Fhttpx/lists"}