Repository: go-resty/resty (go)

Issue:
Feature Request: export `NoRedirectPolicy`'s error 
this is what we do to know it's a redirect problem:


```golang
	resp, err := h.R().SetResult(&r).Get(...)
	if err != nil {
		if err.Error() == "auto redirect is disabled" {
			return APISubject{}, errSkip
		}
		panic(err)
	}
```

if the error of `NoRedirectPolicy` is exported, we can use `errors.Is(err, resty.ErrNotAllowed)` to match the error.

Pull request description:
feat: export NoRedirectPolicy error
closes #569

Patch:
diff --git a/client.go b/client.go
index fb0f70a..6f53ef7 100644
--- a/client.go
+++ b/client.go
@@ -792,7 +792,7 @@ func (c *Client) SetRetryResetReaders(b bool) *Client {
 //
 // Note: This method overwrites existing `TLSClientConfig`.
 func (c *Client) SetTLSClientConfig(config *tls.Config) *Client {
-	transport, err := c.transport()
+	transport, err := c.Transport()
 	if err != nil {
 		c.log.Errorf("%v", err)
 		return c
@@ -809,7 +809,7 @@ func (c *Client) SetTLSClientConfig(config *tls.Config) *Client {
 //
 // Refer to godoc `http.ProxyFromEnvironment`.
 func (c *Client) SetProxy(proxyURL string) *Client {
-	transport, err := c.transport()
+	transport, err := c.Transport()
 	if err != nil {
 		c.log.Errorf("%v", err)
 		return c
@@ -830,7 +830,7 @@ func (c *Client) SetProxy(proxyURL string) *Client {
 //
 //	client.RemoveProxy()
 func (c *Client) RemoveProxy() *Client {
-	transport, err := c.transport()
+	transport, err := c.Transport()
 	if err != nil {
 		c.log.Errorf("%v", err)
 		return c
@@ -1140,7 +1140,7 @@ func (c *Client) execute(req *Request) (*Response, error) {
 
 // getting TLS client config if not exists then create one
 func (c *Client) tlsConfig() (*tls.Config, error) {
-	transport, err := c.transport()
+	transport, err := c.Transport()
 	if err != nil {
 		return nil, err
 	}
@@ -1152,7 +1152,7 @@ func (c *Client) tlsConfig() (*tls.Config, error) {
 
 // Transport method returns `*http.Transport` currently in use or error
 // in case currently used `transport` is not a `*http.Transport`.
-func (c *Client) transport() (*http.Transport, error) {
+func (c *Client) Transport() (*http.Transport, error) {
 	if transport, ok := c.httpClient.Transport.(*http.Transport); ok {
 		return transport, nil
 	}
diff --git a/redirect.go b/redirect.go
index 3b26eb2..fdca9fe 100644
--- a/redirect.go
+++ b/redirect.go
@@ -12,6 +12,10 @@ import (
 	"strings"
 )
 
+var (
+	ErrAutoRedirectDisabled = errors.New("auto redirect is disabled")
+)
+
 type (
 	// RedirectPolicy to regulate the redirects in the resty client.
 	// Objects implementing the RedirectPolicy interface can be registered as
@@ -37,7 +41,7 @@ func (f RedirectPolicyFunc) Apply(req *http.Request, via []*http.Request) error
 //	resty.SetRedirectPolicy(NoRedirectPolicy())
 func NoRedirectPolicy() RedirectPolicy {
 	return RedirectPolicyFunc(func(req *http.Request, via []*http.Request) error {
-		return errors.New("auto redirect is disabled")
+		return ErrAutoRedirectDisabled
 	})
 }
 


Test patch:
diff --git a/client_test.go b/client_test.go
index 90c2bee..72dfd08 100644
--- a/client_test.go
+++ b/client_test.go
@@ -249,7 +249,7 @@ func TestClientSetCertificates(t *testing.T) {
 	client := dc()
 	client.SetCertificates(tls.Certificate{})
 
-	transport, err := client.transport()
+	transport, err := client.Transport()
 
 	assertNil(t, err)
 	assertEqual(t, 1, len(transport.TLSClientConfig.Certificates))
@@ -259,7 +259,7 @@ func TestClientSetRootCertificate(t *testing.T) {
 	client := dc()
 	client.SetRootCertificate(filepath.Join(getTestDataPath(), "sample-root.pem"))
 
-	transport, err := client.transport()
+	transport, err := client.Transport()
 
 	assertNil(t, err)
 	assertNotNil(t, transport.TLSClientConfig.RootCAs)
@@ -269,7 +269,7 @@ func TestClientSetRootCertificateNotExists(t *testing.T) {
 	client := dc()
 	client.SetRootCertificate(filepath.Join(getTestDataPath(), "not-exists-sample-root.pem"))
 
-	transport, err := client.transport()
+	transport, err := client.Transport()
 
 	assertNil(t, err)
 	assertNil(t, transport.TLSClientConfig)
@@ -282,7 +282,7 @@ func TestClientSetRootCertificateFromString(t *testing.T) {
 
 	client.SetRootCertificateFromString(string(rootPemData))
 
-	transport, err := client.transport()
+	transport, err := client.Transport()
 
 	assertNil(t, err)
 	assertNotNil(t, transport.TLSClientConfig.RootCAs)
@@ -296,7 +296,7 @@ func TestClientSetRootCertificateFromStringErrorTls(t *testing.T) {
 	assertNil(t, err)
 	rt := &CustomRoundTripper{}
 	client.SetTransport(rt)
-	transport, err := client.transport()
+	transport, err := client.Transport()
 
 	client.SetRootCertificateFromString(string(rootPemData))
 
@@ -352,7 +352,7 @@ func TestClientSetTransport(t *testing.T) {
 		},
 	}
 	client.SetTransport(transport)
-	transportInUse, err := client.transport()
+	transportInUse, err := client.Transport()
 
 	assertNil(t, err)
 	assertEqual(t, true, transport == transportInUse)
@@ -451,7 +451,7 @@ func TestClientOptions(t *testing.T) {
 	}
 
 	client.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
-	transport, transportErr := client.transport()
+	transport, transportErr := client.Transport()
 
 	assertNil(t, transportErr)
 	assertEqual(t, true, transport.TLSClientConfig.InsecureSkipVerify)
@@ -565,7 +565,7 @@ func TestClientRoundTripper(t *testing.T) {
 	rt := &CustomRoundTripper{}
 	c.SetTransport(rt)
 
-	ct, err := c.transport()
+	ct, err := c.Transport()
 	assertNotNil(t, err)
 	assertNil(t, ct)
 	assertEqual(t, "current transport is not an *http.Transport instance", err.Error())
diff --git a/request_test.go b/request_test.go
index ac4a9f1..59809b4 100644
--- a/request_test.go
+++ b/request_test.go
@@ -1252,7 +1252,7 @@ func TestRawFileUploadByBody(t *testing.T) {
 func TestProxySetting(t *testing.T) {
 	c := dc()
 
-	transport, err := c.transport()
+	transport, err := c.Transport()
 
 	assertNil(t, err)