client

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequestURL = errors.New("invalid request url, we only support https:// or http://")
)

Functions

func DefaultConfigRoot

func DefaultConfigRoot() (string, error)

DefaultConfigRoot will generate the default config path based on the user and his running environment.

Types

type Client

type Client struct {
	*resty.Client
	*Config
}

Client is the wrapper for resty.Client we may provide extra method on this wrapper.

func New

func New(c *Config) (*Client, error)

New will create a resty client with a lot of predefined settings.

func (*Client) CleanCookies added in v0.9.3

func (c *Client) CleanCookies()

func (*Client) SetDefaultHostname added in v0.8.0

func (c *Client) SetDefaultHostname(host string)

type Config

type Config struct {
	HTTPS      bool   // If the request was under the https of http.
	Host       string // The request host name.
	Proxy      string // The proxy address, such as the http://127.0.0.1:7890, socks://127.0.0.1:7890
	ConfigRoot string // The root config path for the whole bookhunter download service.

	// The custom redirect function.
	Redirect resty.RedirectPolicy `json:"-"`
}

Config is the basic configuration for creating the client.

func NewConfig

func NewConfig(rawURL, proxy, configRoot string) (*Config, error)

NewConfig will create a config instance by using the request url.

func (*Config) ConfigPath

func (c *Config) ConfigPath() (string, error)

ConfigPath will return a unique path for this download service.

Jump to

Keyboard shortcuts

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