Documentation
¶
Index ¶
- Constants
- func GetStatusMessage(resp *resty.Response) string
- func IsClientError(resp *resty.Response) bool
- func IsServerError(resp *resty.Response) bool
- func IsSuccess(resp *resty.Response) bool
- type Client
- func (c *Client) Get(ctx context.Context, url string) (*resty.Response, error)
- func (c *Client) GetClient() *resty.Client
- func (c *Client) GetConfig() *Config
- func (c *Client) GetWithHeaders(ctx context.Context, url string, headers map[string]string) (*resty.Response, error)
- func (c *Client) Post(ctx context.Context, url string, body interface{}) (*resty.Response, error)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SetUserAgent(userAgent string)
- type Config
Constants ¶
View Source
const ( // DefaultUserAgent is the default User-Agent string DefaultUserAgent = "urlmap/1.0.0 (+https://github.com/aoshimash/urlmap)" // DefaultTimeout is the default HTTP timeout DefaultTimeout = 30 * time.Second // DefaultRetryCount is the default number of retry attempts DefaultRetryCount = 3 // DefaultRetryWaitTime is the default wait time between retries DefaultRetryWaitTime = 1 * time.Second // DefaultRetryMaxWaitTime is the maximum wait time between retries DefaultRetryMaxWaitTime = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func GetStatusMessage ¶
GetStatusMessage returns a human-readable status message for the response
func IsClientError ¶
IsClientError checks if the HTTP response indicates a client error (4xx status code)
func IsServerError ¶
IsServerError checks if the HTTP response indicates a server error (5xx status code)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Resty client with additional functionality
func NewDefaultClient ¶
func NewDefaultClient() *Client
NewDefaultClient creates a new HTTP client with default configuration
func (*Client) GetWithHeaders ¶
func (c *Client) GetWithHeaders(ctx context.Context, url string, headers map[string]string) (*resty.Response, error)
GetWithHeaders performs a GET request with custom headers
func (*Client) SetTimeout ¶
SetTimeout updates the request timeout
func (*Client) SetUserAgent ¶
SetUserAgent updates the User-Agent string
Click to show internal directories.
Click to hide internal directories.