api

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent() *Agent

func (*Agent) Get

func (a *Agent) Get(user, os string) string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) *Client

func NewClient

func NewClient(cfg *Config, l *log.Logger) (*Client, error)

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

func (*Client) Cookie

func (c *Client) Cookie(url, name string) (http.Cookie, bool)

Cookie 根据url和cookie name获取cookie

func (*Client) Cookies

func (c *Client) Cookies() []*http.Cookie

Cookies 获取当前所有cookies

func (*Client) Download

func (c *Client) Download(ctx context.Context, url string, headers map[string]string, reqBody io.Reader, resp io.Writer, bar *pb.ProgressBar) (*http.Response, error)

func (*Client) GetCSRF

func (c *Client) GetCSRF(url string) (string, bool)

GetCSRF 获取csrf 一般用于weapi接口中使用

func (*Client) GetClient

func (c *Client) GetClient() *http.Client

func (*Client) NewRequest

func (c *Client) NewRequest() *resty.Request

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) Request

func (c *Client) Request(ctx context.Context, url string, req, resp interface{}, opts *Options) (*resty.Response, error)

Request 接口请求

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, url string, headers map[string]string, data io.Reader, resp interface{}, bar *pb.ProgressBar) (*resty.Response, error)

type Config

type Config struct {
	Debug   bool                       `json:"debug" yaml:"debug"`
	Timeout time.Duration              `json:"timeout" yaml:"timeout"`
	Retry   int                        `json:"retry" yaml:"retry"`
	Cookie  cookie.PersistentJarConfig `json:"cookie" yaml:"cookie"`
}

func (*Config) Validate

func (c *Config) Validate() error

type CryptoMode

type CryptoMode string
const (
	CryptoModeAPI   CryptoMode = "api"
	CryptoModeEAPI  CryptoMode = "eapi"
	CryptoModeWEAPI CryptoMode = "weapi"
	CryptoModeLinux CryptoMode = "linux"
)
type Header struct {
}

type Options

type Options struct {
	Method     string
	CryptoMode CryptoMode
	Headers    map[string]string
	Cookies    []*http.Cookie
}

func NewOptions

func NewOptions() *Options

func (*Options) SetCookies

func (o *Options) SetCookies(c ...*http.Cookie)

func (*Options) SetHeader

func (o *Options) SetHeader(key, value string) *Options

func (*Options) SetHeaders

func (o *Options) SetHeaders(h map[string]string) *Options

type UserAgent

type UserAgent struct {
	Android []string `json:"android" yaml:"android"`
	IOS     []string `json:"ios" yaml:"ios"`
	Mac     []string `json:"mac" yaml:"mac"`
	Windows []string `json:"windows" yaml:"windows"`
	Linux   []string `json:"linux" yaml:"linux"`
}

func (*UserAgent) Get

func (u *UserAgent) Get(os string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL