package httpx

import (
	
	

	
)

// BaseURL sets a base URL on the client.
// @group Client Options
//
// Applies to client configuration only.
// Example: client base URL
//
//	c := httpx.New(httpx.BaseURL("https://api.example.com"))
//	_ = c
func ( string) OptionBuilder {
	return OptionBuilder{}.BaseURL()
}

func ( OptionBuilder) ( string) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.req.SetBaseURL()
	}))
}

// Transport wraps the underlying transport with a custom RoundTripper.
// @group Client Options
//
// Applies to client configuration only.
// Example: wrap transport
//
//	c := httpx.New(httpx.Transport(http.RoundTripper(http.DefaultTransport)))
//	_ = c
func ( http.RoundTripper) OptionBuilder {
	return OptionBuilder{}.Transport()
}

func ( OptionBuilder) ( http.RoundTripper) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		if  == nil {
			return
		}
		.req.Transport.WrapRoundTrip(func(http.RoundTripper) http.RoundTripper {
			return 
		})
	}))
}

// Middleware adds request middleware to the client.
// @group Client Options
//
// Applies only to the client configuration.
// Example: add request middleware
//
//	c := httpx.New(httpx.Middleware(func(_ *req.Client, r *req.Request) error {
//		r.SetHeader("X-Trace", "1")
//		return nil
//	}))
//	_ = c
func ( ...req.RequestMiddleware) OptionBuilder {
	return OptionBuilder{}.Middleware(...)
}

func ( OptionBuilder) ( ...req.RequestMiddleware) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		for ,  := range  {
			.req.OnBeforeRequest()
		}
	}))
}

// ErrorMapper sets a custom error mapper for non-2xx responses.
// @group Client Options
//
// Applies only to the client configuration.
// Example: map error responses
//
//	c := httpx.New(httpx.ErrorMapper(func(resp *req.Response) error {
//		return fmt.Errorf("status %d", resp.StatusCode)
//	}))
//	_ = c
func ( ErrorMapperFunc) OptionBuilder {
	return OptionBuilder{}.ErrorMapper()
}

func ( OptionBuilder) ( ErrorMapperFunc) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.errorMapper = 
	}))
}

// Proxy sets a proxy URL for the client.
// @group Client Options
//
// Applies to client configuration only.
// Example: set proxy URL
//
//	c := httpx.New(httpx.Proxy("http://localhost:8080"))
//	_ = c
func ( string) OptionBuilder {
	return OptionBuilder{}.Proxy()
}

func ( OptionBuilder) ( string) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		if  == "" {
			return
		}
		.req.SetProxyURL()
	}))
}

// ProxyFunc sets a proxy function for the client.
// @group Client Options
//
// Applies to client configuration only.
// Example: set proxy function
//
//	c := httpx.New(httpx.ProxyFunc(http.ProxyFromEnvironment))
//	_ = c
func ( func(*http.Request) (*url.URL, error)) OptionBuilder {
	return OptionBuilder{}.ProxyFunc()
}

func ( OptionBuilder) ( func(*http.Request) (*url.URL, error)) OptionBuilder {
	if  == nil {
		return 
	}
	return .add(clientOnly(func( *Client) {
		.req.SetProxy()
	}))
}

// CookieJar sets the cookie jar for the client.
// @group Client Options
//
// Applies to client configuration only.
// Example: set cookie jar and seed cookies
//
//	jar, _ := cookiejar.New(nil)
//	u, _ := url.Parse("https://example.com")
//	jar.SetCookies(u, []*http.Cookie{
//		{Name: "session", Value: "abc123"},
//	})
//	c := httpx.New(httpx.CookieJar(jar))
//	_ = c
func ( http.CookieJar) OptionBuilder {
	return OptionBuilder{}.CookieJar()
}

func ( OptionBuilder) ( http.CookieJar) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		.req.SetCookieJar()
	}))
}

// Redirect sets the redirect policy for the client.
// @group Client Options
//
// Applies to client configuration only.
// Example: disable redirects
//
//	c := httpx.New(httpx.Redirect(req.NoRedirectPolicy()))
//	_ = c
func ( ...req.RedirectPolicy) OptionBuilder {
	return OptionBuilder{}.Redirect(...)
}

func ( OptionBuilder) ( ...req.RedirectPolicy) OptionBuilder {
	return .add(clientOnly(func( *Client) {
		if len() == 0 {
			return
		}
		.req.SetRedirectPolicy(...)
	}))
}