Documentation
¶
Index ¶
- Constants
- type Client
- type Config
- type Option
- func WithConnTimeout(d time.Duration) Option
- func WithDisableHTTP2(disable bool) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithIdleConnTimeout(d time.Duration) Option
- func WithMaxConns(n int) Option
- func WithResponseHeaderTimeout(d time.Duration) Option
- func WithTimeout(d time.Duration) Option
- func WithTransport(tr http.RoundTripper) Option
- type Request
- func NewConnect(baseUrl string) (*Request, error)
- func NewDelete(baseUrl string) (*Request, error)
- func NewGet(baseUrl string) (*Request, error)
- func NewHead(baseUrl string) (*Request, error)
- func NewOptions(baseUrl string) (*Request, error)
- func NewPatch(baseUrl string) (*Request, error)
- func NewPost(baseUrl string) (*Request, error)
- func NewPut(baseUrl string) (*Request, error)
- func NewRequest(method, baseUrl string) (*Request, error)
- func NewTrace(baseUrl string) (*Request, error)
- func (r *Request) AddHeader(key, value string) *Request
- func (r *Request) AddQuery(key, value string) *Request
- func (r *Request) DelHeader(key string) *Request
- func (r *Request) DelQuery(key string) *Request
- func (r *Request) GetBaseUrl() string
- func (r *Request) GetBody() io.Reader
- func (r *Request) GetHeader() http.Header
- func (r *Request) GetMethod() string
- func (r *Request) GetPath() string
- func (r *Request) GetQuery() string
- func (r *Request) GetRawQuery() url.Values
- func (r *Request) GetUrl() string
- func (r *Request) SetBody(body []byte) *Request
- func (r *Request) SetBodyReader(reader io.Reader) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetJSON(body any) (*Request, error)
- func (r *Request) SetPath(path string) *Request
- func (r *Request) SetQuery(key, value string) *Request
- type Response
Constants ¶
View Source
const ( MethodGet = http.MethodGet MethodPost = http.MethodPost MethodPut = http.MethodPut MethodDelete = http.MethodDelete MethodPatch = http.MethodPatch MethodHead = http.MethodHead MethodOptions = http.MethodOptions MethodConnect = http.MethodConnect MethodTrace = http.MethodTrace )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
MaxConns int // Maximum concurrent connections per host
Timeout time.Duration // Total timeout, Timeout >= ResponseTimeout + ConnTimeout
ResponseTimeout time.Duration // Response header timeout
ConnTimeout time.Duration // Connection timeout
IdleConnTimeout time.Duration // Idle connection timeout
DisableHttp2 bool // Disable HTTP/2 when true
}
type Option ¶
type Option func(*Client)
func WithConnTimeout ¶
WithConnTimeout sets TCP connect timeout and TLS handshake timeout
func WithDisableHTTP2 ¶
WithDisableHTTP2 disables HTTP/2 when set to true
func WithHTTPClient ¶
WithHTTPClient overrides the underlying http.Client
func WithIdleConnTimeout ¶
WithIdleConnTimeout sets idle connection timeout
func WithResponseHeaderTimeout ¶
WithResponseHeaderTimeout sets response header timeout
func WithTimeout ¶
WithTimeout sets the overall client timeout
func WithTransport ¶
func WithTransport(tr http.RoundTripper) Option
WithTransport overrides the transport on the underlying http.Client
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewConnect ¶
func NewOptions ¶
func NewRequest ¶
func (*Request) GetBaseUrl ¶
func (*Request) GetRawQuery ¶
func (*Request) SetBodyReader ¶
SetBodyReader allows streaming request body without buffering into memory
type Response ¶
type Response struct {
Status int
StatusText string
Header http.Header
// contains filtered or unexported fields
}
func (*Response) GetBodyBytes ¶
func (*Response) GetBodyString ¶
Click to show internal directories.
Click to hide internal directories.