name: go-resty
description: Use for Resty v3 Go HTTP, REST, and SSE client tasks.
Go Resty
Overview
Resty v3 is a simple HTTP, REST, and server-sent events client library for Go. It uses the resty.dev/v3 module path.
require resty.dev/v3
Resty v3 improves performance, memory efficiency, and features compared to Resty v2. This skill is for Resty v3 and above.
Basic HTTP Client
client := resty.New()
defer client.Close()
res, err := client.R().
EnableTrace().
Get("https://httpbin.org/get")
fmt.Println(err, res)
fmt.Println(res.Request.TraceInfo())
Basic SSE Client
es := NewEventSource().
SetURL("https://sse.dev/test").
OnMessage(func(e any) {
fmt.Println(e.(*resty.Event))
}, nil)
err := es.Get()
fmt.Println(err)
Key Features
- Simple and chainable methods
- Multipart and form data
- Request path parameters
- Retry mechanism
- Circuit breaker and circuit breaker policies
- Goroutine and concurrent safety
- Automatic decompression for gzip and deflate
- Basic auth, digest auth, bearer auth, and custom auth
- Request tracing
- Curl command generation
- HTTP/1.1, HTTP/2, and HTTP/3 integration
- Automatic marshal and unmarshal
- Large file upload and progress callbacks
- Download to file
- Redirect policies
- Human-readable and JSON debug logs
- Load balancing and service discovery
- Response body limits and unlimited reads
- Bazel support
- Dynamic TLS certificate reloads
- Custom root and client certificates
Extension Points
Resty can be extended through these interfaces and hooks:
- Request middleware
- Response middleware
- Content-Type encoder and decoder
- Content decompressor
- Load balancer and service discovery
- Retry strategy, conditions, and hooks
- Circuit breaker policy
- Request functions
- Redirect policy
- Transport
RoundTripper
- Debug log formatter
- Logger
Purpose
Use this skill to work with Resty v3 Go client code. Prefer the bundled references over guessing API names, method placement, defaults, or option semantics.
Workflow
- Identify the Resty feature area from the task.
- Read only the relevant reference files from the index below.
- Confirm whether the code targets Resty v3. If the code uses Resty v2 imports or APIs, call out the version mismatch before applying v3 patterns.
- Preserve existing project conventions for client construction, error handling, context use, logging, tests, and dependency injection.
- When adding or changing code, verify with the repository's Go tooling when available, such as
go test ./..., focused package tests, or go test for the touched package.
Request Construction
- Request bodies:
references/request-body-types.md
- Query parameters:
references/request-query-params.md
- Path and raw path parameters:
references/request-path-params.md
- Form data:
references/form-data.md
- Multipart forms and file uploads:
references/multipart.md
- Payloads on methods that usually omit request bodies:
references/allow-payload-on.md
Authentication And Security
- Basic, digest, bearer, custom header, and middleware auth:
references/authentication.md
- Root CA certificates:
references/root-certificates.md
- Client root CA certificates:
references/client-root-certificates.md
- Client certificates and mTLS:
references/client-certificates.md
- OAuth2 client credentials example:
references/example-oauth2-client-credentials.md
- TLS config on a custom RoundTripper example:
references/example-tls-client-config-on-custom-roundtriper.md
Reliability And Networking
- Timeouts:
references/timeout.md
- Retry mechanism, retry conditions, hooks, and backoff:
references/retry-mechanism.md
- Circuit breaker:
references/circuit-breaker.md
- Hedging:
references/hedging.md
- Redirect policies:
references/redirect-policy.md
- Load balancer and service discovery:
references/load-balancer-and-service-discovery.md
- SOCKS5 proxy example:
references/example-socks5-proxy.md
- Custom DNS resolver example:
references/example-custom-dns-resolver.md
- HTTP/3 example:
references/example-enable-http3.md
Middleware And Extension Points
- Request middleware:
references/request-middleware.md
- Response middleware:
references/response-middleware.md
- Content-Type encoders and decoders:
references/content-type-encoder-and-decoder.md
- Content decompressers:
references/content-decompresser.md
- Brotli decompression example:
references/example-decompress-brotli.md
- Zstandard decompression example:
references/example-decompress-zstandard.md
Response Handling And Observability
- Automatic response parsing:
references/response-auto-parse.md
- Save response to file:
references/save-response.md
- Unlimited response body reads:
references/unlimited-response-body-reads.md
- Request tracing:
references/request-tracing.md
- Curl command generation:
references/curl-command.md
- Debug logging:
references/debug-log.md
- Redirect history example:
references/example-redirect-history.md
- Dry run example:
references/example-how-to-do-dry-run.md
HTTP Methods And SSE Examples
- GET request example:
references/example-get-request.md
- POST, PUT, and PATCH request example:
references/example-post-put-patch-request.md
- DELETE request example:
references/example-delete-request.md
- OPTIONS, HEAD, and TRACE request example:
references/example-options-head-trace-request.md
- Server-sent events:
references/server-sent-events.md
Version And Feature Notes
- New features and enhancements:
references/new-features-and-enhancements.md
Error Handling
- If a requested API is not found in the selected reference file, search the other Resty references before inventing method names.
- If the project uses
github.com/go-resty/resty/v2, avoid applying resty.dev/v3 examples without explicitly migrating the import and API usage.
- If behavior depends on transport, TLS, redirects, or retries, read the specific reference for that feature before changing defaults.
1---2name: go-resty3description: Use for Resty v3 Go HTTP, REST, and SSE client tasks.4---5---6name: go-resty7description: Use for Resty v3 Go HTTP, REST, and SSE client tasks.8---910# Go Resty1112## Overview1314Resty v3 is a simple HTTP, REST, and server-sent events client library for Go. It uses the `resty.dev/v3` module path.1516```go17require resty.dev/v318```1920Resty v3 improves performance, memory efficiency, and features compared to Resty v2. This skill is for Resty v3 and above.2122### Basic HTTP Client2324```go25client := resty.New()26defer client.Close()2728res, err := client.R().29 EnableTrace().30 Get("https://httpbin.org/get")31fmt.Println(err, res)32fmt.Println(res.Request.TraceInfo())33```3435### Basic SSE Client3637```go38es := NewEventSource().39 SetURL("https://sse.dev/test").40 OnMessage(func(e any) {41 fmt.Println(e.(*resty.Event))42 }, nil)4344err := es.Get()45fmt.Println(err)46```4748### Key Features4950- Simple and chainable methods51- Multipart and form data52- Request path parameters53- Retry mechanism54- Circuit breaker and circuit breaker policies55- Goroutine and concurrent safety56- Automatic decompression for gzip and deflate57- Basic auth, digest auth, bearer auth, and custom auth58- Request tracing59- Curl command generation60- HTTP/1.1, HTTP/2, and HTTP/3 integration61- Automatic marshal and unmarshal62- Large file upload and progress callbacks63- Download to file64- Redirect policies65- Human-readable and JSON debug logs66- Load balancing and service discovery67- Response body limits and unlimited reads68- Bazel support69- Dynamic TLS certificate reloads70- Custom root and client certificates7172### Extension Points7374Resty can be extended through these interfaces and hooks:7576- Request middleware77- Response middleware78- Content-Type encoder and decoder79- Content decompressor80- Load balancer and service discovery81- Retry strategy, conditions, and hooks82- Circuit breaker policy83- Request functions84- Redirect policy85- Transport `RoundTripper`86- Debug log formatter87- Logger8889## Purpose9091Use this skill to work with Resty v3 Go client code. Prefer the bundled references over guessing API names, method placement, defaults, or option semantics.9293## Workflow94951. Identify the Resty feature area from the task.962. Read only the relevant reference files from the index below.973. Confirm whether the code targets Resty v3. If the code uses Resty v2 imports or APIs, call out the version mismatch before applying v3 patterns.984. Preserve existing project conventions for client construction, error handling, context use, logging, tests, and dependency injection.995. When adding or changing code, verify with the repository's Go tooling when available, such as `go test ./...`, focused package tests, or `go test` for the touched package.100101## Request Construction102103- Request bodies: `references/request-body-types.md`104- Query parameters: `references/request-query-params.md`105- Path and raw path parameters: `references/request-path-params.md`106- Form data: `references/form-data.md`107- Multipart forms and file uploads: `references/multipart.md`108- Payloads on methods that usually omit request bodies: `references/allow-payload-on.md`109110## Authentication And Security111112- Basic, digest, bearer, custom header, and middleware auth: `references/authentication.md`113- Root CA certificates: `references/root-certificates.md`114- Client root CA certificates: `references/client-root-certificates.md`115- Client certificates and mTLS: `references/client-certificates.md`116- OAuth2 client credentials example: `references/example-oauth2-client-credentials.md`117- TLS config on a custom RoundTripper example: `references/example-tls-client-config-on-custom-roundtriper.md`118119## Reliability And Networking120121- Timeouts: `references/timeout.md`122- Retry mechanism, retry conditions, hooks, and backoff: `references/retry-mechanism.md`123- Circuit breaker: `references/circuit-breaker.md`124- Hedging: `references/hedging.md`125- Redirect policies: `references/redirect-policy.md`126- Load balancer and service discovery: `references/load-balancer-and-service-discovery.md`127- SOCKS5 proxy example: `references/example-socks5-proxy.md`128- Custom DNS resolver example: `references/example-custom-dns-resolver.md`129- HTTP/3 example: `references/example-enable-http3.md`130131## Middleware And Extension Points132133- Request middleware: `references/request-middleware.md`134- Response middleware: `references/response-middleware.md`135- Content-Type encoders and decoders: `references/content-type-encoder-and-decoder.md`136- Content decompressers: `references/content-decompresser.md`137- Brotli decompression example: `references/example-decompress-brotli.md`138- Zstandard decompression example: `references/example-decompress-zstandard.md`139140## Response Handling And Observability141142- Automatic response parsing: `references/response-auto-parse.md`143- Save response to file: `references/save-response.md`144- Unlimited response body reads: `references/unlimited-response-body-reads.md`145- Request tracing: `references/request-tracing.md`146- Curl command generation: `references/curl-command.md`147- Debug logging: `references/debug-log.md`148- Redirect history example: `references/example-redirect-history.md`149- Dry run example: `references/example-how-to-do-dry-run.md`150151## HTTP Methods And SSE Examples152153- GET request example: `references/example-get-request.md`154- POST, PUT, and PATCH request example: `references/example-post-put-patch-request.md`155- DELETE request example: `references/example-delete-request.md`156- OPTIONS, HEAD, and TRACE request example: `references/example-options-head-trace-request.md`157- Server-sent events: `references/server-sent-events.md`158159## Version And Feature Notes160161- New features and enhancements: `references/new-features-and-enhancements.md`162163## Error Handling164165- If a requested API is not found in the selected reference file, search the other Resty references before inventing method names.166- If the project uses `github.com/go-resty/resty/v2`, avoid applying `resty.dev/v3` examples without explicitly migrating the import and API usage.167- If behavior depends on transport, TLS, redirects, or retries, read the specific reference for that feature before changing defaults.