Thanks to visit codestin.com
Credit goes to resty.dev

NOTE: Currently, Resty v3 is in beta release

Simple HTTP, REST, and SSE client library for Go

Resty Build Status Resty Code Coverage Go Report Card Resty GoDoc Mentioned in Awesome Go

require resty.dev/v3 v3.0.0-beta.6
Minimum required Go version is go1.23
  • // HTTP, REST 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())
  • // Server-Sent Events Client
    es := NewEventSource().
        SetURL("https://sse.dev/test").
        OnMessage(func(e any) {
            fmt.Println(e.(*resty.Event))
        }, nil)
    
    err := es.Get()
    fmt.Println(err)

Resty v3 offers improved performance, memory efficiency, and features compared to Resty v2.

This website represents Resty v3 and above. For previous v2 documentation, refer to this README.md

Key Features#

    • Simple and chainable methods
    • Multipart and Form data with ease
    • Request Path Params
    • Retry Mechanism
    • Circuit Breaker
    • Goroutine & concurrent safe
    • Automatic decompresser (gzip, deflate)
    • Basic auth, Digest auth, Bearer, etc.
    • Request tracing
    • CURL command generation
    • HTTP/1.1 and HTTP/2. Integrate HTTP/3
    • Circuit Breaker Policy

    and much more ...

    • Automatic marshal and unmarshal
    • Large file upload and progress callback
    • Download to file
    • Redirect Policies
    • Debug mode with human-readable, JSON log
    • Load Balancer and Service Discovery
    • Response body limit & Unlimited reads
    • Bazel support
    • Dynamic reload of TLS certificates
    • Custom root and client certificates

    and much more ...

Highly Extensible#

Resty provides various ways to enhance its functionality by implementing its interfaces to meet all custom requirements.

  • Request middleware
  • Response middleware
  • Content-Type encoder & decoder
  • Content Decompresser
  • Load Balancer and Service Discovery
  • Retry Strategy, Condition, and Hooks
  • Circuit Breaker Policy
  • Request Functions
  • Redirect Policy
  • Transport RoundTripper
  • Debug Log Formatter
  • Logger
Copied!