Resty

A simple, chainable HTTP and REST client for Go with built-in retries, middleware, and auth helpers.

Library
Go
vv2.17.2
11,769stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity60
Maintenance80
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
71/100Good
Architecture80
Code Quality82
Innovation55
Learning Curve65

Resty is a Go library for making HTTP and REST calls with a fluent, chainable API inspired by Ruby’s rest-client. Instead of hand-assembling net/http requests, developers build requests through methods like SetHeader, SetBody, SetResult, and SetQueryParam, with automatic JSON/XML marshaling and unmarshaling based on content type.

Beyond the basic request/response cycle, Resty ships with production-oriented features out of the box: configurable backoff retries with custom retry conditions, request/response middleware hooks, cookie jar support, Basic and Bearer auth, digest authentication, TLS and certificate configuration, path and query parameter helpers, multipart file uploads, redirect policies, SRV-record-based requests, and on-demand curl command generation for debugging.

The library has been stable and widely adopted in the Go ecosystem since 2015, with the v2 module line (github.com/go-resty/resty/v2) maintained as the long-term stable API while newer experimental work happens on a separate v3 branch. It is goroutine-safe and designed so a single *resty.Client can be reused across an application.

What You Get

  • Chainable client and request builders (SetHeader, SetBody, SetQueryParam, SetPathParams, SetResult, SetError) instead of manual http.Request construction
  • Automatic marshal/unmarshal of JSON and XML request and response bodies, including RFC7807 problem-detail error responses
  • Configurable backoff retry mechanism with custom RetryConditionFunc predicates and OnRetryFunc hooks
  • Request and response middleware pipeline (OnBeforeRequest / OnAfterResponse) for cross-cutting concerns like logging or auth injection
  • Built-in Basic Auth, Bearer token, and full HTTP Digest authentication support
  • Multipart file upload helpers with automatic content-type detection
  • TLS root certificate and client certificate configuration, plus pluggable http.RoundTripper transport
  • Redirect policies (NoRedirectPolicy, FlexibleRedirectPolicy, DomainCheckRedirectPolicy) and SRV-record-based host resolution
  • Request tracing (EnableTrace) exposing DNS lookup, connection, and TLS handshake timings
  • On-demand curl command generation for a request when debug mode is enabled, useful for reproducing failing calls outside the app

Common Use Cases

  • Calling third-party REST APIs from a Go backend with automatic JSON decoding into typed structs via SetResult/SetError
  • Building internal service-to-service HTTP clients that need retry-with-backoff and consistent auth headers across every call
  • Uploading files or form-encoded multipart payloads to an API endpoint without manually constructing multipart.Writer boilerplate
  • Debugging flaky external API integrations by enabling Resty’s debug logging and curl-command generation to see exactly what was sent
  • Talking to APIs that require HTTP Digest authentication, which the standard library does not implement

Under The Hood

Architecture Resty centers on a *Client (created via resty.New(), wrapping a standard *http.Client with a public-suffix-aware cookie jar) and a *Request built per call through Client.R(). Execution runs each request through an ordered chain of RequestMiddleware functions defined in middleware.go (URL/path-param interpolation, header assembly, body encoding) before handing off to the wrapped http.Client.Do, then through a parallel ResponseMiddleware chain (body decoding into SetResult/SetError targets, RFC7807 handling) on the way back. Retry logic in retry.go wraps this whole cycle with configurable backoff, jitter, and pluggable RetryConditionFunc/OnRetryFunc hooks rather than being baked into the core request path, and digest authentication (digest.go) is implemented as a separate middleware that intercepts a 401 challenge and replays the request with computed credentials. This keeps the core request/response cycle small while letting orthogonal concerns (retries, auth, tracing) plug in as middleware rather than branching logic in the client itself.

Tech Stack Resty v2 is dependency-light: golang.org/x/net for the public-suffix list used by the cookie jar, and golang.org/x/time for rate-limiting-adjacent time utilities, are its only non-stdlib requirements per go.mod/go.sum. Everything else — the HTTP transport (transport.go, with build-tagged variants for js/wasm vs. standard targets in transport_js.go/transport_other.go), TLS handling, and multipart encoding — is built directly on net/http, net/url, crypto/tls, and mime/multipart from the Go standard library. The module targets Go 1.23+ and is published under the versioned import path github.com/go-resty/resty/v2, Go’s mechanism for a library’s major-version-2 release.

Code Quality The v2 branch carries nine _test.go files (client, context, curl, digest, middleware, request, resty, retry, util) alongside their corresponding implementation files, indicating close 1:1 test coverage of the public surface, plus an example_test.go providing runnable, godoc-indexed usage examples. Comment density in the core files is high — client.go alone is roughly a third comments — with doc comments following Go convention (exported identifiers documented, [Type.Method] cross-reference links used throughout for godoc). Error handling favors explicit sentinel errors (e.g. ErrAutoRedirectDisabled) and wrapped errors via errors/fmt.Errorf rather than panics. CI (GitHub Actions) runs the build/test matrix against both the stable and pinned 1.23.x Go toolchains on every push and PR to the v2 branch.

API Design The chainable-setter style (client.R().SetHeader(...).SetResult(...).Get(url)) reads close to natural language and keeps a single call expression readable even with many options, following the pattern popularized by Ruby’s rest-client and widely imitated in other Go HTTP clients. Getting started requires almost no boilerplate — resty.New().R().Get(url) is a complete request — while still exposing the underlying *http.Request/*http.Response for callers who need lower-level access. Method and field naming is consistent (Set* for configuration, Enable*/Disable* for toggles), and the maintainers document breaking-change intent explicitly in code (e.g. the deprecated HostURL field points callers to BaseURL), which lowers the risk of silent behavior changes across upgrades.

Used by 11 apps in this directory

Go
72%
GPL 3.0

1Panel

Devops · Hosting Control Panel · Monitoring

36,721

The only open-source VPS control panel with native AI agent runtime — deploy websites, Docker stacks, and local LLMs from one web interface.

View details
90
Repo Health
76
Technical
68
Dependency
Built with
Go72%
Vue28%
Updated 2 days ago
Go
60%
Apache 2.0

Apache Answer

Community

15,658

Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility

View details
84
Repo Health
78
Technical
68
Dependency
Built with
Go60%
TypeScript36%
Updated 2 days ago
Go
90%
Apache 2.0

CasaOS

Hosting Control Panel · File Storage

37,163

Your simple, elegant personal cloud OS for home data and apps

View details
51
Repo Health
71
Technical
65
Dependency
Built with
Go90%
Updated 1 years ago
Shell
48%
MIT

Dokku

Devops · Hosting Control Panel

32,114

The smallest PaaS implementation you've ever seen — deploy apps via git push using Docker and Heroku buildpacks on your own server.

View details
93
Repo Health
85
Technical
71
Dependency
Built with
Shell48%
Go48%
Updated today
TypeScript
97%
Other

Infisical

Security · Devops

29,028

The open-source platform for secrets, certificates, privileged access, and AI agent security — all in one self-hostable system.

View details
91
Repo Health
84
Technical
66
Dependency
Built with
TypeScript97%
Updated yesterday
Go
56%
Other

Multica

AI Assistants · AI Development

48,263

Turn coding agents into real teammates — assign issues, track progress, and compound reusable skills across a vendor-neutral, self-hosted platform.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Go56%
TypeScript39%
Updated today
Go
48%
Apache 2.0

opencloud

File Storage

5,868

Open source file management and collaboration platform that keeps your data under your control, no database required.

View details
85
Repo Health
80
Technical
69
Dependency
Built with
Go48%
Gherkin36%
PHP12%
Updated yesterday
Go
78%
Apache 2.0

OpenMeter

Invoicing Finance · Developer Tools

2,236

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
86
Repo Health
81
Technical
66
Dependency
Built with
Go78%
TypeScript17%
Updated 2 days ago
Go
75%
AGPL 3.0

Teleport

Security · Authentication

20,860

Zero-trust infrastructure access platform that replaces credentials and VPNs with short-lived certificates, SSO, and identity-aware proxies for SSH, Kubernetes, databases, RDP, and AI agents.

View details
94
Repo Health
81
Technical
69
Dependency
Built with
Go75%
TypeScript16%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search