Documentation ¶
Overview ¶
this package is a basic implementation of APIClient
Index ¶
- Constants
- Variables
- func FakeUA(ua apitypes.UserAgentType) string
- type Client
- func (c *Client) Cookie(u *url.URL, name string) (*http.Cookie, bool)
- func (c *Client) Cookies(u *url.URL) []*http.Cookie
- func (c *Client) HasCookie(u *url.URL, name string) bool
- func (c *Client) Req(method string, url string, data apitypes.H, opt *apitypes.RequestOption) (*apitypes.APIResponse, error)
- func (c *Client) ReqID(method string, url string, data apitypes.H, opt *apitypes.RequestOption) string
- func (c *Client) Request(r *apitypes.APIRequest) (*apitypes.APIResponse, error)
- func (c *Client) RequestID(r *apitypes.APIRequest) string
- func (c *Client) SetCookies(u *url.URL, cookies []*http.Cookie)
- func (c *Client) SyncCookiesFromLocal()
- func (c *Client) WriteCookies(cs []*http.Cookie) error
- type ClientConfig
- type ClientErr
Constants ¶
View Source
const CookieTmpDir = "/var/tmp/ncmapi_client_cookies"
Variables ¶
View Source
var BaseURL = url.URL{
Scheme: "https",
Host: "music.163.com",
}
Functions ¶
func FakeUA ¶
func FakeUA(ua apitypes.UserAgentType) string
Types ¶
type Client ¶
type Client struct { *http.Client Config *ClientConfig }
func NewClient ¶
func NewClient(cfg *ClientConfig) *Client
func (*Client) Req ¶
func (c *Client) Req(method string, url string, data apitypes.H, opt *apitypes.RequestOption) (*apitypes.APIResponse, error)
func (*Client) Request ¶
func (c *Client) Request(r *apitypes.APIRequest) (*apitypes.APIResponse, error)
func (*Client) SyncCookiesFromLocal ¶
func (c *Client) SyncCookiesFromLocal()
type ClientConfig ¶
type ClientConfig struct { // if true, client will read cookies from local & preserve cookie to local when exit PreserveCookies bool // logs LogHttpRequest bool LogHttpResponse bool }
func DefaultConfig ¶
func DefaultConfig() *ClientConfig
Click to show internal directories.
Click to hide internal directories.