Documentation ¶
Index ¶
- Constants
- Variables
- func ErrFromCode(code int) error
- func Get(client *resty.Client, url string, options *GetOptions) (*resty.Response, error)
- func GetURLHost(sourceURL string) (string, error)
- func NewRestyClient() *resty.Client
- func NewRestyClientWithOptions(options ClientOptions) *resty.Client
- func Post(client *resty.Client, options *PostOptions) (*resty.Response, error)
- type ClientOptions
- type GetOptions
- type PostOptions
Constants ¶
View Source
const ( // ProtocolRegexp HTTP 协议正则 ProtocolRegexp = "http(s)?://" // DefaultPortStr HTTP 默认端口 DefaultPortStr = "80" )
Variables ¶
View Source
var ( ErrBadRequest = errors.New(http.StatusText(http.StatusBadRequest)) ErrForbidden = errors.New(http.StatusText(http.StatusForbidden)) ErrNotFound = errors.New(http.StatusText(http.StatusNotFound)) ErrInternalServerError = errors.New(http.StatusText(http.StatusInternalServerError)) )
View Source
var ( // ErrPostOptionsRequired defines the error returned when post options is nil ErrPostOptionsRequired = errors.New("post options required") // ErrPostURLRequired defines the error returned when post url is empty ErrPostURLRequired = errors.New("post url required") )
Functions ¶
func ErrFromCode ¶
func Get ¶
func Get(client *resty.Client, url string, options *GetOptions) (*resty.Response, error)
Get send get request with options
func GetURLHost ¶
func NewRestyClient ¶
func NewRestyClient() *resty.Client
func NewRestyClientWithOptions ¶
func NewRestyClientWithOptions(options ClientOptions) *resty.Client
func Post ¶
func Post(client *resty.Client, options *PostOptions) (*resty.Response, error)
Post send post request with options
Types ¶
type ClientOptions ¶
type ClientOptions struct { RetryAttempts int RetryWaitTime time.Duration RetryMaxWaitTime time.Duration }
ClientOptions ...
Click to show internal directories.
Click to hide internal directories.