Documentation ¶
Index ¶
- Constants
- func Delete(url string, rfs ...RequestFunc) (*resty.Response, error)
- func Download(url, path string, rfs ...RequestFunc) error
- func Fetch(c *FetchConf) (contents []byte, err error)
- func FormFetch(c *FetchConf) (contents []byte, err error)
- func Get(url string, rfs ...RequestFunc) (*resty.Response, error)
- func Head(url string, rfs ...RequestFunc) (*resty.Response, error)
- func JwtUnauthorizedResult(w http.ResponseWriter, r *http.Request, err error)
- func NewErrorFromRestyResponse(res *resty.Response) *errorx.Error
- func Options(url string, rfs ...RequestFunc) (*resty.Response, error)
- func Patch(url string, rfs ...RequestFunc) (*resty.Response, error)
- func Post(url string, rfs ...RequestFunc) (*resty.Response, error)
- func Put(url string, rfs ...RequestFunc) (*resty.Response, error)
- func RespError(w http.ResponseWriter, r *http.Request, err error)
- func RespSuccess(ctx context.Context, w http.ResponseWriter, resp interface{})
- func Stringify(v interface{}) string
- type Client
- func (c *Client) Delete(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Get(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Head(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Options(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Patch(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Post(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Put(url string, rfs ...RequestFunc) (*resty.Response, error)
- func (c *Client) Request(method, url string, rfs ...RequestFunc) (*resty.Response, error)
- type ClientFunc
- func SetAuthScheme(scheme string) ClientFunc
- func SetAuthToken(token string) ClientFunc
- func SetBaseURI(uri string) ClientFunc
- func SetBasicAuth(username, password string) ClientFunc
- func SetClientHeader(header, value string) ClientFunc
- func SetHostURL(url string) ClientFunc
- func SetIgnoreCodes(codes ...int) ClientFunc
- func SetProxy(proxyURL string) ClientFunc
- func SetRetryCount(count int) ClientFunc
- func SetRetryWaitTime(waitTime time.Duration) ClientFunc
- func SetTLSClientConfig(config *tls.Config) ClientFunc
- func UnsetTimeout() ClientFunc
- type FetchConf
- type RequestFunc
- func ForceContentType(contentType string) RequestFunc
- func SetBody(body interface{}) RequestFunc
- func SetFileReader(param, fileName string, reader io.Reader) RequestFunc
- func SetFormData(data map[string]string) RequestFunc
- func SetHeader(header, value string) RequestFunc
- func SetHeaders(headers map[string]string) RequestFunc
- func SetHeadersFromHTTPHeader(header http.Header) RequestFunc
- func SetPathParam(param, value string) RequestFunc
- func SetPathParams(params map[string]string) RequestFunc
- func SetQueryParam(param, value string) RequestFunc
- func SetQueryParams(params map[string]string) RequestFunc
- func SetQueryParamsFromValues(params url.Values) RequestFunc
- func SetResult(res interface{}) RequestFunc
- type Response
Constants ¶
View Source
const ( UserAgent = "HiBug Client" TimeoutSeconds = 60 MaxRetryCount = 3 )
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(url string, rfs ...RequestFunc) (*resty.Response, error)
func Download ¶
func Download(url, path string, rfs ...RequestFunc) error
Download retrieves content from the given url and write it to path.
func Get ¶
func Get(url string, rfs ...RequestFunc) (*resty.Response, error)
func Head ¶
func Head(url string, rfs ...RequestFunc) (*resty.Response, error)
func JwtUnauthorizedResult ¶
func JwtUnauthorizedResult(w http.ResponseWriter, r *http.Request, err error)
func Options ¶
func Options(url string, rfs ...RequestFunc) (*resty.Response, error)
func Patch ¶
func Patch(url string, rfs ...RequestFunc) (*resty.Response, error)
func Post ¶
func Post(url string, rfs ...RequestFunc) (*resty.Response, error)
func Put ¶
func Put(url string, rfs ...RequestFunc) (*resty.Response, error)
func RespSuccess ¶
func RespSuccess(ctx context.Context, w http.ResponseWriter, resp interface{})
Types ¶
type Client ¶
type Client struct { *resty.Client Host string // Host is the fully qualified domain name of the system, or an IP Address. Port and protocol are required if necessary. BaseURI string // BaseURI is the base uri for every request, starting with a slash, for example: /api/v1 //IgnoreCodes sets.Int // IgnoreCodes ignores some code to be returned as an error. IgnoreCodes sets.Set[int] }
func New ¶
func New(cfs ...ClientFunc) *Client
func (*Client) Delete ¶
func (c *Client) Delete(url string, rfs ...RequestFunc) (*resty.Response, error)
func (*Client) Head ¶
func (c *Client) Head(url string, rfs ...RequestFunc) (*resty.Response, error)
func (*Client) Options ¶
func (c *Client) Options(url string, rfs ...RequestFunc) (*resty.Response, error)
func (*Client) Patch ¶
func (c *Client) Patch(url string, rfs ...RequestFunc) (*resty.Response, error)
type ClientFunc ¶
type ClientFunc func(*Client)
func SetAuthScheme ¶
func SetAuthScheme(scheme string) ClientFunc
func SetAuthToken ¶
func SetAuthToken(token string) ClientFunc
func SetBaseURI ¶
func SetBaseURI(uri string) ClientFunc
func SetBasicAuth ¶
func SetBasicAuth(username, password string) ClientFunc
func SetClientHeader ¶
func SetClientHeader(header, value string) ClientFunc
func SetHostURL ¶
func SetHostURL(url string) ClientFunc
func SetIgnoreCodes ¶
func SetIgnoreCodes(codes ...int) ClientFunc
func SetProxy ¶
func SetProxy(proxyURL string) ClientFunc
func SetRetryCount ¶
func SetRetryCount(count int) ClientFunc
func SetRetryWaitTime ¶
func SetRetryWaitTime(waitTime time.Duration) ClientFunc
func SetTLSClientConfig ¶
func SetTLSClientConfig(config *tls.Config) ClientFunc
func UnsetTimeout ¶
func UnsetTimeout() ClientFunc
type RequestFunc ¶
type RequestFunc func(request *resty.Request)
func ForceContentType ¶
func ForceContentType(contentType string) RequestFunc
func SetBody ¶
func SetBody(body interface{}) RequestFunc
func SetFileReader ¶ added in v0.2.2
func SetFileReader(param, fileName string, reader io.Reader) RequestFunc
func SetFormData ¶
func SetFormData(data map[string]string) RequestFunc
func SetHeader ¶
func SetHeader(header, value string) RequestFunc
func SetHeaders ¶
func SetHeaders(headers map[string]string) RequestFunc
func SetHeadersFromHTTPHeader ¶
func SetHeadersFromHTTPHeader(header http.Header) RequestFunc
func SetPathParam ¶ added in v0.2.1
func SetPathParam(param, value string) RequestFunc
func SetPathParams ¶ added in v0.2.1
func SetPathParams(params map[string]string) RequestFunc
func SetQueryParam ¶
func SetQueryParam(param, value string) RequestFunc
func SetQueryParams ¶
func SetQueryParams(params map[string]string) RequestFunc
func SetQueryParamsFromValues ¶
func SetQueryParamsFromValues(params url.Values) RequestFunc
func SetResult ¶
func SetResult(res interface{}) RequestFunc
Click to show internal directories.
Click to hide internal directories.