Documentation ¶
Index ¶
- Variables
- type APIClient
- type APIError
- type APIResponse
- type BasicClient
- func (c *BasicClient) CookieJar() fhttp.CookieJar
- func (c *BasicClient) DefaultHeader() http.Header
- func (c *BasicClient) HTTPClient() tlsclient.HttpClient
- func (c *BasicClient) Log(ctx context.Context, params clog.Params)
- func (c *BasicClient) Logger() *slog.Logger
- func (c *BasicClient) Request(ctx context.Context, method string, url string, body io.Reader, ...) (*fhttp.Response, error)
- func (c *BasicClient) SetCookieJar(jar fhttp.CookieJar)
- func (c *BasicClient) SetCookies(u *url.URL, cookies []*fhttp.Cookie)
- func (c *BasicClient) SetDefaultHeader(header http.Header)
- func (c *BasicClient) SetLogger(logger *slog.Logger)
- type Client
- type ClientConfigOption
- type URLParams
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultClientHeader = http.Header{ "Accept": {"*/*"}, "Accept-Language": {"en-US,en;q=0.7"}, "Cache-Control": {"no-cache"}, "Pragma": {"no-cache"}, "User-Agent": {"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"}, fhttp.HeaderOrderKey: { "Accept", "Accept-Language", "User-Agent", }, }
View Source
var DefaultHTTPClientOptions = []tlsclient.HttpClientOption{ tlsclient.WithTimeoutSeconds(10), tlsclient.WithClientProfile(profiles.Chrome_105), }
View Source
var NilClient = errors.New("client is nil")
View Source
var NilClientConfig = errors.New("config is nil")
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient interface { Client() Client Logger() *slog.Logger SetLogger(logger *slog.Logger) Log(ctx context.Context, params clog.Params) BaseURL() string SetBaseURL(baseURL string) DefaultHeader() http.Header SetDefaultHeader(defaultHeader http.Header) Request(ctx context.Context, method string, endpointURI string, urlParams URLParams, headers http.Header, bodyData interface{}) (response APIResponse, err error) RawRequest(ctx context.Context, method string, url string, headers http.Header, body io.Reader) (response APIResponse, err error) }
type APIError ¶
type APIError struct { Response *APIResponse `json:"response"` Code int `json:"code"` Header http.Header `json:"header"` Message string `json:"message"` // contains filtered or unexported fields }
type APIResponse ¶
type BasicClient ¶
type BasicClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientConfigOption) (*BasicClient, error)
func (*BasicClient) CookieJar ¶
func (c *BasicClient) CookieJar() fhttp.CookieJar
func (*BasicClient) DefaultHeader ¶
func (c *BasicClient) DefaultHeader() http.Header
func (*BasicClient) HTTPClient ¶
func (c *BasicClient) HTTPClient() tlsclient.HttpClient
func (*BasicClient) Logger ¶
func (c *BasicClient) Logger() *slog.Logger
func (*BasicClient) SetCookieJar ¶
func (c *BasicClient) SetCookieJar(jar fhttp.CookieJar)
func (*BasicClient) SetCookies ¶
func (c *BasicClient) SetCookies(u *url.URL, cookies []*fhttp.Cookie)
func (*BasicClient) SetDefaultHeader ¶
func (c *BasicClient) SetDefaultHeader(header http.Header)
func (*BasicClient) SetLogger ¶
func (c *BasicClient) SetLogger(logger *slog.Logger)
type Client ¶
type Client interface { HTTPClient() tlsclient.HttpClient DefaultHeader() http.Header SetDefaultHeader(header http.Header) Logger() *slog.Logger SetLogger(logger *slog.Logger) Log(ctx context.Context, params clog.Params) CookieJar() fhttp.CookieJar SetCookieJar(jar fhttp.CookieJar) SetCookies(u *url.URL, cookies []*fhttp.Cookie) Request(ctx context.Context, method string, url string, body io.Reader, headers http.Header) (*fhttp.Response, error) }
type ClientConfigOption ¶
type ClientConfigOption func(cfg *clientConfig)
func WithDefaultHeader ¶
func WithDefaultHeader(defaultHeader http.Header) ClientConfigOption
func WithHTTPClient ¶
func WithHTTPClient(httpClient tlsclient.HttpClient) ClientConfigOption
func WithHTTPClientOptions ¶
func WithHTTPClientOptions(httpClientOptions []tlsclient.HttpClientOption) ClientConfigOption
func WithLogger ¶
func WithLogger(logger *slog.Logger) ClientConfigOption
Click to show internal directories.
Click to hide internal directories.