Versions in this module Expand all Collapse all v0 v0.5.0 Feb 19, 2026 Changes in this version + func DefaultRetryChecker(resp *Response, err error, attempt int) bool + func NewTransport(onCreate func(ht *http.Transport)) *http.Transport type Builder + func (b *Builder) RemoveHeaders(keys ...string) *Builder type Client + Header http.Header + MaxRetries int + Method string + ReqVars map[string]string + RespDecoder RespDecoder + RetryChecker RetryChecker + RetryDelay int + Timeout int + func NewClient(baseURL ...string) *Client + func (h *Client) ConfigDoer(fn func(doer httpreq.Doer)) *Client + func (h *Client) DefaultTimeout(timeoutMs int) *Client + func (h *Client) Download(url, savePath string, optFns ...OptionFn) (int, error) + func (h *Client) SetMaxIdleConns(maxIdleConns, maxIdleConnsPerHost int) *Client + func (h *Client) UploadFile(pathURL, fieldName, filePath string, optFns ...OptionFn) (*Response, error) + func (h *Client) UploadFiles(pathURL string, files map[string]string, optFns ...OptionFn) (*Response, error) + func (h *Client) UploadWithData(pathURL string, files map[string]string, fields map[string]string, ...) (*Response, error) + func (h *Client) WithBaseURL(baseURL string) *Client + func (h *Client) WithMaxRetries(maxRetries int) *Client + func (h *Client) WithRetryChecker(checker RetryChecker) *Client + func (h *Client) WithRetryConfig(maxRetries, retryDelay int, checker RetryChecker) *Client + func (h *Client) WithRetryDelay(retryDelay int) *Client type OptionFn + func WithBody(body any) OptionFn + func WithData(data any) OptionFn + func WithHeader(key, value string) OptionFn + func WithMaxRetries(maxRetries int) OptionFn + func WithRetry(maxRetries, retryDelay int, checker RetryChecker) OptionFn + func WithRetryChecker(checker RetryChecker) OptionFn + func WithRetryDelay(retryDelay int) OptionFn + func WithTimeout(timeoutMs int) OptionFn type Options + MaxRetries int + RetryChecker RetryChecker + RetryDelay int type Response + CostTime int64 + func NewResponse(resp *http.Response, decoder RespDecoder) *Response + type RetryChecker func(resp *Response, err error, attempt int) bool v0.4.1 Oct 13, 2025 v0.4.0 Nov 19, 2024 v0.3.0 Jun 24, 2023 Changes in this version + const AgentCURL + const HeaderAuth + const HeaderUAgent + func MergeURLValues(uv gourl.Values, values ...any) gourl.Values + func SetHeaderMap(req *http.Request, headerMap map[string]string) + func SetHeaders(req *http.Request, headers ...http.Header) + type AfterSendFn func(resp *Response, err error) + type Builder struct + func BuilderWithClient(c *Client, optFns ...OptionFn) *Builder + func NewBuilder(fns ...OptionFn) *Builder + func (b *Builder) AddHeader(key, value string) *Builder + func (b *Builder) AddHeaderMap(headers map[string]string) *Builder + func (b *Builder) AddHeaders(headers http.Header) *Builder + func (b *Builder) AddQuery(key string, value any) *Builder + func (b *Builder) AnyBody(body any) *Builder + func (b *Builder) BasicAuth(username, password string) *Builder + func (b *Builder) BodyProvider(bp BodyProvider) *Builder + func (b *Builder) BodyReader(r io.Reader) *Builder + func (b *Builder) Build(method, pathURL string) (*http.Request, error) + func (b *Builder) BytesBody(bs []byte) *Builder + func (b *Builder) Delete(pathURL string, optFns ...OptionFn) *Builder + func (b *Builder) DeleteDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (b *Builder) Do(optFns ...OptionFn) (*Response, error) + func (b *Builder) FileContentsBody(filePath string) *Builder + func (b *Builder) FormBody(formData any) *Builder + func (b *Builder) FormType() *Builder + func (b *Builder) Get(pathURL string, optFns ...OptionFn) *Builder + func (b *Builder) GetDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (b *Builder) JSONBody(jsonData any) *Builder + func (b *Builder) JSONType() *Builder + func (b *Builder) Multipart(key, value string) *Builder + func (b *Builder) MultipartType() *Builder + func (b *Builder) Patch(pathURL string, data any, optFns ...OptionFn) *Builder + func (b *Builder) PatchDo(pathURL string, data any, optFns ...OptionFn) (*Response, error) + func (b *Builder) PathURL(pathURL string) *Builder + func (b *Builder) Post(pathURL string, data any, optFns ...OptionFn) *Builder + func (b *Builder) PostDo(pathURL string, data any, optFns ...OptionFn) (*Response, error) + func (b *Builder) Put(pathURL string, data any, optFns ...OptionFn) *Builder + func (b *Builder) PutDo(pathURL string, data any, optFns ...OptionFn) (*Response, error) + func (b *Builder) QueryParams(ps any) *Builder + func (b *Builder) QueryValues(values gourl.Values) *Builder + func (b *Builder) Send(method, url string, optFns ...OptionFn) (*Response, error) + func (b *Builder) SetHeader(key, value string) *Builder + func (b *Builder) SetHeaderMap(headers map[string]string) *Builder + func (b *Builder) SetHeaders(headers http.Header) *Builder + func (b *Builder) String() string + func (b *Builder) StringBody(s string) *Builder + func (b *Builder) UserAgent(ua string) *Builder + func (b *Builder) UserAuth(value string) *Builder + func (b *Builder) WithBody(body any) *Builder + func (b *Builder) WithClient(c *Client) *Builder + func (b *Builder) WithContentType(value string) *Builder + func (b *Builder) WithCookieString(value string) *Builder + func (b *Builder) WithCookies(hcs ...*http.Cookie) *Builder + func (b *Builder) WithMethod(method string) *Builder + func (b *Builder) WithOptionFn(fns ...OptionFn) *Builder + func (b *Builder) WithOptionFns(fns []OptionFn) *Builder + func (b *Builder) WithQuerySMap(smp map[string]string) *Builder + func (b *Builder) WithType(value string) *Builder + func (b *Builder) XMLType() *Builder + type Client struct + AfterSend AfterSendFn + BeforeSend func(r *http.Request) + ContentType string + Vars map[string]string + func (h *Client) AnyBody(body any) *Builder + func (h *Client) BaseURL(baseURL string) *Client + func (h *Client) BasicAuth(username, password string) *Builder + func (h *Client) Body(body any) *Builder + func (h *Client) BodyProvider(bp BodyProvider) *Builder + func (h *Client) BodyReader(r io.Reader) *Builder + func (h *Client) Builder(optFns ...OptionFn) *Builder + func (h *Client) Client(doer httpreq.Doer) *Client + func (h *Client) Config(fn func(doer httpreq.Doer)) *Client + func (h *Client) ConfigHClient(fn func(hClient *http.Client)) *Client + func (h *Client) DefaultBasicAuth(username, password string) *Client + func (h *Client) DefaultContentType(value string) *Client + func (h *Client) DefaultHeader(key, value string) *Client + func (h *Client) DefaultHeaders(headers http.Header) *Client + func (h *Client) DefaultMethod(method string) *Client + func (h *Client) DefaultUserAgent(value string) *Client + func (h *Client) DefaultUserAuth(value string) *Client + func (h *Client) Delete(pathURL string) *Builder + func (h *Client) DeleteDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) Do(method, url string, optFns ...OptionFn) (*Response, error) + func (h *Client) DoWithOption(method, url string, optFns ...OptionFn) (*Response, error) + func (h *Client) Doer(doer httpreq.Doer) *Client + func (h *Client) FormType() *Builder + func (h *Client) Get(pathURL string) *Builder + func (h *Client) GetDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) Head(pathURL string) *Builder + func (h *Client) HeadDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) HttpClient(hClient *http.Client) *Client + func (h *Client) JSONType() *Builder + func (h *Client) Middleware(middles ...Middleware) *Client + func (h *Client) Middlewares(middles ...Middleware) *Client + func (h *Client) MustSend(method, url string, optFns ...OptionFn) *Response + func (h *Client) NewRequest(method, url string, optFns ...OptionFn) (*http.Request, error) + func (h *Client) NewRequestWithOptions(url string, opt *Options) (*http.Request, error) + func (h *Client) OnBeforeSend(fn func(r *http.Request)) *Client + func (h *Client) Patch(pathURL string) *Builder + func (h *Client) PatchDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) Post(pathURL string) *Builder + func (h *Client) PostDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) Put(pathURL string) *Builder + func (h *Client) PutDo(pathURL string, optFns ...OptionFn) (*Response, error) + func (h *Client) QueryParams(ps any) *Builder + func (h *Client) Send(method, url string, optFns ...OptionFn) (*Response, error) + func (h *Client) SendRaw(raw string, varMp map[string]string) (*Response, error) + func (h *Client) SendRequest(req *http.Request) (*Response, error) + func (h *Client) SendWithOpt(pathURL string, opt *Options) (*Response, error) + func (h *Client) SendWithOption(method, url string, optFns ...OptionFn) (*Response, error) + func (h *Client) String() string + func (h *Client) Sub() *Client + func (h *Client) Use(middles ...Middleware) *Client + func (h *Client) UserAgent(value string) *Builder + func (h *Client) UserAuth(value string) *Builder + func (h *Client) Uses(middles ...Middleware) *Client + func (h *Client) WithContentType(value string) *Builder + func (h *Client) WithRespDecoder(respDecoder RespDecoder) *Client + type OptionFn func(opt *Options) + func WithContentType(contentType string) OptionFn + func WithMethod(method string) OptionFn + func WithUserAgent(userAgent string) OptionFn + type Options struct + Body any + ContentType string + Context context.Context + Data any + EncodeJSON bool + Header http.Header + HeaderM map[string]string + Logger httpreq.ReqLogger + Method string + Provider BodyProvider + Query gourl.Values + QueryM map[string]any + TCancelFn context.CancelFunc + Timeout int + func NewOpt(fns ...OptionFn) *Options + func NewOpt2(fns []OptionFn, method string) *Options type Response + func HeadDo(pathURL string, optFns ...OptionFn) (*Response, error) + func Must(w *Response, err error) *Response + func MustDo(method, pathURL string, optFns ...OptionFn) *Response + func SendDo(method, pathURL string, optFns ...OptionFn) (*Response, error) + func (r *Response) SaveFile(file string) (err error) v0.2.0 Aug 9, 2022 Changes in this version + var DefaultDoer = http.DefaultClient + func ToString(r *http.Request, err error) string + type BodyProvider interface + Body func() (io.Reader, error) + ContentType func() string + type HandleFunc func(r *http.Request) (*Response, error) + type HiReq struct + func BaseURL(baseURL string) *HiReq + func New(baseURL ...string) *HiReq + func Reset() *HiReq + func Std() *HiReq + func (h *HiReq) AddHeader(key, value string) *HiReq + func (h *HiReq) AddHeaders(headers http.Header) *HiReq + func (h *HiReq) BaseURL(baseURL string) *HiReq + func (h *HiReq) BasicAuth(username, password string) *HiReq + func (h *HiReq) Body(body interface{}) *HiReq + func (h *HiReq) BodyProvider(bp BodyProvider) *HiReq + func (h *HiReq) BodyReader(r io.Reader) *HiReq + func (h *HiReq) Build(pathURLAndMethod ...string) (*http.Request, error) + func (h *HiReq) BytesBody(bs []byte) *HiReq + func (h *HiReq) Client(doer httpreq.Doer) *HiReq + func (h *HiReq) Config(fn func(doer httpreq.Doer)) *HiReq + func (h *HiReq) ConfigHClient(fn func(hClient *http.Client)) *HiReq + func (h *HiReq) Connect(pathURL string) (*Response, error) + func (h *HiReq) ConnectDo(pathURL string) (*Response, error) + func (h *HiReq) ContentType(value string) *HiReq + func (h *HiReq) Delete(pathURL string) *HiReq + func (h *HiReq) DeleteDo(pathURL string) (*Response, error) + func (h *HiReq) Do(pathURLAndMethod ...string) (*Response, error) + func (h *HiReq) DoWithCtx(ctx context.Context, pathURLAndMethod ...string) (*Response, error) + func (h *HiReq) Doer(doer httpreq.Doer) *HiReq + func (h *HiReq) FileContentsBody(filepath string) *HiReq + func (h *HiReq) FormBody(formData interface{}) *HiReq + func (h *HiReq) FormType() *HiReq + func (h *HiReq) Get(pathURL string) *HiReq + func (h *HiReq) GetDo(pathURL string) (*Response, error) + func (h *HiReq) Head(pathURL string) *HiReq + func (h *HiReq) HeadDo(pathURL string) (*Response, error) + func (h *HiReq) HttpClient(hClient *http.Client) *HiReq + func (h *HiReq) JSONBody(jsonData interface{}) *HiReq + func (h *HiReq) JSONType() *HiReq + func (h *HiReq) Method(method string) *HiReq + func (h *HiReq) Middleware(middles ...Middleware) *HiReq + func (h *HiReq) Middlewares(middles ...Middleware) *HiReq + func (h *HiReq) Multipart(key, value string) *HiReq + func (h *HiReq) MultipartType() *HiReq + func (h *HiReq) MustSend(pathURLAndMethod ...string) *Response + func (h *HiReq) New() *HiReq + func (h *HiReq) NewRequest(pathURLAndMethod ...string) (*http.Request, error) + func (h *HiReq) NewRequestWithCtx(ctx context.Context, pathURLAndMethod ...string) (*http.Request, error) + func (h *HiReq) Options(pathURL string) *HiReq + func (h *HiReq) OptionsDo(pathURL string) (*Response, error) + func (h *HiReq) Patch(pathURL string) *HiReq + func (h *HiReq) PatchDo(pathURL string) (*Response, error) + func (h *HiReq) PathURL(pathURL string) *HiReq + func (h *HiReq) Post(pathURL string) *HiReq + func (h *HiReq) PostDo(pathURL string) (*Response, error) + func (h *HiReq) Put(pathURL string) *HiReq + func (h *HiReq) PutDo(pathURL string) (*Response, error) + func (h *HiReq) QueryParam(key string, value interface{}) *HiReq + func (h *HiReq) QueryParams(ps interface{}) *HiReq + func (h *HiReq) QueryValues(values url.Values) *HiReq + func (h *HiReq) Send(pathURLAndMethod ...string) (*Response, error) + func (h *HiReq) SendRaw(raw string) (*Response, error) + func (h *HiReq) SendRequest(req *http.Request) (*Response, error) + func (h *HiReq) SendWithCtx(ctx context.Context, pathURLAndMethod ...string) (*Response, error) + func (h *HiReq) SetCookieString(value string) *HiReq + func (h *HiReq) SetCookies(hcs ...*http.Cookie) *HiReq + func (h *HiReq) SetHeader(key, value string) *HiReq + func (h *HiReq) SetHeaders(headers http.Header) *HiReq + func (h *HiReq) String() string + func (h *HiReq) StringBody(s string) *HiReq + func (h *HiReq) Trace(pathURL string) *HiReq + func (h *HiReq) TraceDo(pathURL string) (*Response, error) + func (h *HiReq) Use(middles ...Middleware) *HiReq + func (h *HiReq) UserAgent(value string) *HiReq + func (h *HiReq) UserAuth(value string) *HiReq + func (h *HiReq) Uses(middles ...Middleware) *HiReq + func (h *HiReq) WithRespDecoder(respDecoder RespDecoder) *HiReq + func (h *HiReq) XMLType() *HiReq + type MiddleFunc func(r *http.Request, next HandleFunc) (*Response, error) + func (mf MiddleFunc) Handle(r *http.Request, next HandleFunc) (*Response, error) + type Middleware interface + Handle func(r *http.Request, next HandleFunc) (*Response, error) + type RequestCreator interface + NewRequest func(method, target string, body io.Reader) *http.Request + type RequestCreatorFunc func(method, target string, body io.Reader) *http.Request + type RespDecoder interface + Decode func(resp *http.Response, ptr interface{}) error + type Response struct + func ConnectDo(pathURL string) (*Response, error) + func DeleteDo(pathURL string) (*Response, error) + func GetDo(pathURL string) (*Response, error) + func Head(pathURL string) (*Response, error) + func OptionsDo(pathURL string) (*Response, error) + func PatchDo(pathURL string, body ...interface{}) (*Response, error) + func PostDo(pathURL string, body ...interface{}) (*Response, error) + func PutDo(pathURL string, body ...interface{}) (*Response, error) + func TraceDo(pathURL string) (*Response, error) + func (r *Response) BodyBuffer() *bytes.Buffer + func (r *Response) BodyString() string + func (r *Response) CloseBody() error + func (r *Response) ContentType() string + func (r *Response) Decode(ptr interface{}) error + func (r *Response) HeaderString() string + func (r *Response) IsContentType(prefix string) bool + func (r *Response) IsEmptyBody() bool + func (r *Response) IsFail() bool + func (r *Response) IsJSONType() bool + func (r *Response) IsOK() bool + func (r *Response) IsSuccessful() bool + func (r *Response) QuietCloseBody() + func (r *Response) Result() *http.Response + func (r *Response) SetDecoder(decoder RespDecoder) + func (r *Response) String() string + type XmlDecoder struct + func (d XmlDecoder) Decode(resp *http.Response, ptr interface{}) error