Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,29 @@ type: docs
<div class="resty-go-min">Minimum required Go version is {{% param Resty.V3.GoMinVersion %}}</div>

{{% columns %}}
```go
// 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())
```
<--->
```go
// 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)
```

- ```go
// 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())
```

- ```go
// 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)
```
{{% /columns %}}

<p align="center">Resty v3 offers improved performance, memory efficiency, and features compared to Resty v2.</p>
Expand All @@ -67,6 +66,7 @@ This website represents Resty v3 and above. For previous v2 documentation, refer
## Key Features

{{% columns %}}

* Simple and chainable methods
* Multipart and Form data with ease
* Request Path Params
Expand All @@ -78,8 +78,6 @@ This website represents Resty v3 and above. For previous v2 documentation, refer
* Request tracing
* CURL command generation
* HTTP/1.1 and HTTP/2. Integrate HTTP/3


<p class="ml-20">and much more ...</p>

<--->
Expand All @@ -95,8 +93,8 @@ This website represents Resty v3 and above. For previous v2 documentation, refer
* Bazel support
* Dynamic reload of TLS certificates
* Custom root and client certificates

<p class="ml-20">and much more ...</p>

{{% /columns %}}

## Highly Extensible
Expand Down
17 changes: 7 additions & 10 deletions content/docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ client.R().

## Digest Auth

{{% hint info %}}
Digest auth is supported only at the client level; create a dedicated client to utilize it.
{{% /hint %}}
> [!NOTE]
> Digest auth is supported only at the client level; create a dedicated client to utilize it.

Supported QOP -
* `auth`
Expand All @@ -48,9 +47,8 @@ client.SetDigestAuth("username", "password")

## Bearer Auth Token

{{% hint info %}}
The default auth scheme is `Bearer`, which can be changed with [Client.SetAuthScheme]({{% godoc v3 %}}Client.SetAuthScheme) or [Request.SetAuthScheme]({{% godoc v3 %}}Request.SetAuthScheme)
{{% /hint %}}
> [!NOTE]
> The default auth scheme is `Bearer`, which can be changed with [Client.SetAuthScheme]({{% godoc v3 %}}Client.SetAuthScheme) or [Request.SetAuthScheme]({{% godoc v3 %}}Request.SetAuthScheme)

```go
// for all requests
Expand All @@ -68,10 +66,9 @@ client.R().

For application/service that user custom HTTP header for authentication/authorization.

{{% hint info %}}
* The default authorization key is `Authorization`.
* The default auth scheme is `Bearer`, which can be changed with [Client.SetAuthScheme]({{% godoc v3 %}}Client.SetAuthScheme) or [Request.SetAuthScheme]({{% godoc v3 %}}Request.SetAuthScheme)
{{% /hint %}}
> [!NOTE]
> * The default authorization key is `Authorization`.
> * The default auth scheme is `Bearer`, which can be changed with [Client.SetAuthScheme]({{% godoc v3 %}}Client.SetAuthScheme) or [Request.SetAuthScheme]({{% godoc v3 %}}Request.SetAuthScheme)

```go
client.SetHeaderAuthorizationKey("X-Custom-Auth")
Expand Down
5 changes: 2 additions & 3 deletions content/docs/circuit-breaker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

A circuit breaker is used to improve system stability and resiliency. It is different from the retry mechanism.

{{% hint info %}}
**Hint:** Combining the Circuit Breaker with [Retry Mechanism]({{% relref "retry-mechanism" %}}) typically provides a comprehensive approach to handling failures.
{{% /hint %}}
> [!NOTE]
> **Hint:** Combining the Circuit Breaker with [Retry Mechanism]({{% relref "retry-mechanism" %}}) typically provides a comprehensive approach to handling failures.

## Default Values

Expand Down
7 changes: 3 additions & 4 deletions content/docs/client-root-certificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ weight: 6

Resty offers a convenient method to add `client root` certificates.

{{% hint info %}}
* Starting v3, Resty lets a watcher reload certificates dynamically at configured intervals if modified.
* Default watcher reload interval is 24 hours.
{{% /hint %}}
> [!NOTE]
> * Starting v3, Resty lets a watcher reload certificates dynamically at configured intervals if modified.
> * Default watcher reload interval is 24 hours.

## Examples

Expand Down
11 changes: 5 additions & 6 deletions content/docs/content-decompresser.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ weight: 7

Resty v3 provides an extensible way to handle Response content decompression. Out-of-the-box, it handles `gzip` and `deflate` decompress.

{{% hint info %}}
**NOTE:**
* User-defined decompresser takes priority over default ones.
* Add method overwrites decompresser if `decompress` directive/key already exists.
* [Content-Encoding directive/key](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) is important while adding decompresser.
{{% /hint %}}
> [!NOTE]
> **NOTE:**
> * User-defined decompresser takes priority over default ones.
> * Add method overwrites decompresser if `decompress` directive/key already exists.
> * [Content-Encoding directive/key](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) is important while adding decompresser.

## Example

Expand Down
9 changes: 4 additions & 5 deletions content/docs/content-type-encoder-and-decoder.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ weight: 7

Resty v3 provides an extensible way to handle Request and Response content types. Out-of-the-box, it handles `JSON` and `XML` content types.

{{% hint info %}}
**NOTE:**
* User-defined encoder/decoder takes priority over default ones.
* Add method overwrites encoder/decoder if `Content-Type` key already exists.
{{% /hint %}}
> [!NOTE]
> **NOTE:**
> * User-defined encoder/decoder takes priority over default ones.
> * Add method overwrites encoder/decoder if `Content-Type` key already exists.

## Examples

Expand Down
11 changes: 5 additions & 6 deletions content/docs/curl-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ By default, Resty does not log the curl command in the debug log since it has th

{{% hintreqoverride %}}

{{% hint warning %}}
**NOTE:**
- Potential to leak sensitive data from [Request]({{% godoc v3 %}}Request) and [Response]({{% godoc v3 %}}Response) in the debug log when the debug log option is enabled.
- Additional memory usage since the request body was reread.
- curl body is not generated for `io.Reader` and multipart request flow.
{{% /hint %}}
> [!WARNING]
> **NOTE:**
> - Potential to leak sensitive data from [Request]({{% godoc v3 %}}Request) and [Response]({{% godoc v3 %}}Response) in the debug log when the debug log option is enabled.
> - Additional memory usage since the request body was reread.
> - curl body is not generated for `io.Reader` and multipart request flow.

## Example

Expand Down
5 changes: 2 additions & 3 deletions content/docs/example/decompress-brotli.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

Resty v3 allows users to add decompression logic for HTTP responses using their favorite package.

{{% hint info %}}
Using `sync.Pool` can reuse the reader and reduce allocation if the package supports `Reset`.
{{% /hint %}}
> [!NOTE]
> Using `sync.Pool` can reuse the reader and reduce allocation if the package supports `Reset`.

## Example 1

Expand Down
5 changes: 2 additions & 3 deletions content/docs/example/decompress-zstandard.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

Resty v3 allows users to add decompression logic for HTTP responses using their favorite package.

{{% hint info %}}
Using `sync.Pool` can reuse the reader and reduce allocation if the package supports `Reset`.
{{% /hint %}}
> [!NOTE]
> Using `sync.Pool` can reuse the reader and reduce allocation if the package supports `Reset`.

## Example

Expand Down
7 changes: 3 additions & 4 deletions content/docs/example/delete-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ weight: 2

This page discusses simple DELETE requests. Users can utilize Resty features across nearly all HTTP methods.

{{% hint info %}}
* Explore the documentation to fulfill all use cases.
* Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.
{{% /hint %}}
> [!NOTE]
> * Explore the documentation to fulfill all use cases.
> * Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.

## Examples

Expand Down
7 changes: 3 additions & 4 deletions content/docs/example/get-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ weight: 1

This page discusses simple GET requests. Users can utilize Resty features across nearly all HTTP methods.

{{% hint info %}}
* Explore the documentation to fulfill all use cases.
* Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.
{{% /hint %}}
> [!NOTE]
> * Explore the documentation to fulfill all use cases.
> * Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.

## Examples

Expand Down
16 changes: 7 additions & 9 deletions content/docs/example/oauth2-client-credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ title: OAuth2 Client Credentials

## Without Modifying

{{% hint info %}}
As per the GoDoc of [clientcredentials#Config.Client](https://pkg.go.dev/golang.org/x/oauth2/clientcredentials#Config.Client)
* The returned `Client` and its `Transport` should not be modified.
{{% /hint %}}
> [!NOTE]
> As per the GoDoc of [clientcredentials#Config.Client](https://pkg.go.dev/golang.org/x/oauth2/clientcredentials#Config.Client)
> * The returned `Client` and its `Transport` should not be modified.

```go
clientCredCfg := &clientcredentials.Config{
Expand All @@ -34,11 +33,10 @@ defer c.Close()

This scenario applies to any client and transport-related configurations, such as adding Root CA, Client Root CA, Client SSL certificates, transport timeouts, and so on.

{{% hint info %}}
* As per the GoDoc of [clientcredentials#Config.Client](https://pkg.go.dev/golang.org/x/oauth2/clientcredentials#Config.Client)
* The returned `Client` and its `Transport` should not be modified.
* To use the oauth2 client credentials package and make modifications to it, a minor adjustment is necessary.
{{% /hint %}}
> [!NOTE]
> * As per the GoDoc of [clientcredentials#Config.Client](https://pkg.go.dev/golang.org/x/oauth2/clientcredentials#Config.Client)
> * The returned `Client` and its `Transport` should not be modified.
> * To use the oauth2 client credentials package and make modifications to it, a minor adjustment is necessary.

```go
clientCredCfg := &clientcredentials.Config{
Expand Down
7 changes: 3 additions & 4 deletions content/docs/example/options-head-trace-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ weight: 2

This page discusses simple OPTIONS, HEAD, and TRACE requests. Users can utilize Resty features across nearly all HTTP methods.

{{% hint info %}}
* Explore the documentation to fulfill all use cases.
* Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.
{{% /hint %}}
> [!NOTE]
> * Explore the documentation to fulfill all use cases.
> * Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.

## Examples

Expand Down
7 changes: 3 additions & 4 deletions content/docs/example/post-put-patch-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ weight: 1

This page discusses simple POST, PUT, and PATCH requests. Users can utilize Resty features across nearly all HTTP methods.

{{% hint info %}}
* Explore the documentation to fulfill all use cases.
* Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.
{{% /hint %}}
> [!NOTE]
> * Explore the documentation to fulfill all use cases.
> * Examples use request-level methods; however, Resty also includes client-level methods to configure settings for all requests.

## Examples

Expand Down
9 changes: 4 additions & 5 deletions content/docs/form-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

Resty provides a convenient method to compose form-data requests.

{{% hint info %}}
* By default, only allowed on payload-supported HTTP verbs, see [allow payload on]({{% relref "allow-payload-on" %}}).
* Request `Content-Type` set as `application/x-www-form-urlencoded`.
* Form data values are `URL-encoded`.
{{% /hint %}}
> [!NOTE]
> * By default, only allowed on payload-supported HTTP verbs, see [allow payload on]({{% relref "allow-payload-on" %}}).
> * Request `Content-Type` set as `application/x-www-form-urlencoded`.
> * Form data values are `URL-encoded`.

{{% hintreqoverride %}}

Expand Down
7 changes: 3 additions & 4 deletions content/docs/load-balancer-and-service-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ Out of the box, Resty provides two algorithms -

Also, SRV records discovery using the Weighted Round-Robin (WRR) algorithm, called []().

{{% hint info %}}
* Version 2 had an SRV record lookup feature but did not utilize a record weight value. Version 3 respects the record weight value and executes the appropriate weighted round-robin.
* Version 3 enables Resty users to implement any custom method for determining the Base URL through the [LoadBalancer]({{% godoc v3 %}}LoadBalancer) interface.
{{% /hint %}}
> [!NOTE]
> * Version 2 had an SRV record lookup feature but did not utilize a record weight value. Version 3 respects the record weight value and executes the appropriate weighted round-robin.
> * Version 3 enables Resty users to implement any custom method for determining the Base URL through the [LoadBalancer]({{% godoc v3 %}}LoadBalancer) interface.

## Examples

Expand Down
22 changes: 10 additions & 12 deletions content/docs/multipart.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

Resty provides a convenient method to compose multipart form-data or ordered form-data requests.

{{% hint info %}}
* Only allowed on POST, PUT, and PATCH verbs.
* Starting v3, ordered multipart form data is possible.
* [Request.SetMultipartBoundary]({{% godoc v3 %}}Request.SetMultipartBoundary) setting custom boundary can be used together.
* All form data and multipart methods can be used together.
{{% /hint %}}
> [!NOTE]
> * Only allowed on POST, PUT, and PATCH verbs.
> * Starting v3, ordered multipart form data is possible.
> * [Request.SetMultipartBoundary]({{% godoc v3 %}}Request.SetMultipartBoundary) setting custom boundary can be used together.
> * All form data and multipart methods can be used together.

```go
res, err := client.R().
Expand Down Expand Up @@ -70,12 +69,11 @@ fmt.Println(err, res)

# Multipart File Upload

{{% hint info %}}
* By default, Resty streams the content in the request body when a file or `io.Reader` is detected in the MultipartField input.
* Only allowed on POST, PUT, and PATCH verbs.
* [Request.SetMultipartBoundary]({{% godoc v3 %}}Request.SetMultipartBoundary) setting custom boundary can be used together.
* All form data and multipart methods can be used together.
{{% /hint %}}
> [!NOTE]
> * By default, Resty streams the content in the request body when a file or `io.Reader` is detected in the MultipartField input.
> * Only allowed on POST, PUT, and PATCH verbs.
> * [Request.SetMultipartBoundary]({{% godoc v3 %}}Request.SetMultipartBoundary) setting custom boundary can be used together.
> * All form data and multipart methods can be used together.

## Upload

Expand Down
5 changes: 2 additions & 3 deletions content/docs/redirect-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ Out of the box, it has following redirect polices:
* [FlexibleRedirectPolicy]({{% godoc v3 %}}FlexibleRedirectPolicy)
* [DomainCheckRedirectPolicy]({{% godoc v3 %}}DomainCheckRedirectPolicy)

{{% hint info %}}
v3 [NoRedirectPolicy]({{% godoc v3 %}}NoRedirectPolicy) returns an error `http.ErrUseLastResponse`.
{{% /hint %}}
> [!NOTE]
> v3 [NoRedirectPolicy]({{% godoc v3 %}}NoRedirectPolicy) returns an error `http.ErrUseLastResponse`.

## Example

Expand Down
Loading