restclient

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHttpTimeout          = 5
	DefaultTcpConnectionTimeout = 30
)

Todo 请求方法需要重构,加入header参数

View Source
const DefaultDNSCacheExpireTime = int64(600)

Variables

This section is empty.

Functions

func LoadEndpointFromEnv

func LoadEndpointFromEnv() string

Types

type Dialer added in v0.2.4

type Dialer struct {
	Resolver *Resolver
	Dialer   net.Dialer
}

func (*Dialer) DialContext added in v0.2.4

func (dialer *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type HttpNotOk

type HttpNotOk struct {
	Status     string
	StatusCode int
	RequestId  string
	Body       []byte
}

func NewHttpNotOk

func NewHttpNotOk(res *http.Response) HttpNotOk

func (HttpNotOk) Error

func (e HttpNotOk) Error() string

type Resolver added in v0.2.4

type Resolver struct {
	CacheTimeSeconds int64
	// contains filtered or unexported fields
}

func NewResolver added in v0.2.4

func NewResolver(cacheTime int64) *Resolver

func (*Resolver) Lookup added in v0.2.4

func (r *Resolver) Lookup(ctx context.Context, host string) ([]string, error)

type RestClient

type RestClient struct {
	account.Account
	// It is the total time from the tcp connection to http response.
	// the default value is 0, represents no timeout
	HttpTimeout          time.Duration
	TcpConnectionTimeout time.Duration
	DnsCacheExpireTime   time.Duration
	DisableCompression   bool
	// contains filtered or unexported fields
}

func NewOdpsRestClient

func NewOdpsRestClient(a account.Account, endpoint string) RestClient

func (*RestClient) Do

func (client *RestClient) Do(req *http.Request) (*http.Response, error)

func (*RestClient) DoWithModel

func (client *RestClient) DoWithModel(req *http.Request, model interface{}) error

func (*RestClient) DoWithParseFunc

func (client *RestClient) DoWithParseFunc(req *http.Request, parseFunc func(res *http.Response) error) error

func (*RestClient) DoWithParseRes

func (client *RestClient) DoWithParseRes(req *http.Request, parseFunc func(res *http.Response) error) error

func (*RestClient) DoXmlWithModel

func (client *RestClient) DoXmlWithModel(
	method string,
	resource string,
	queryArgs url.Values,
	bodyModel interface{},
	resModel interface{}) error

func (*RestClient) DoXmlWithParseFunc

func (client *RestClient) DoXmlWithParseFunc(
	method string,
	resource string,
	queryArgs url.Values,
	headers map[string]string,
	bodyModel interface{},
	parseFunc func(res *http.Response) error) error

func (*RestClient) DoXmlWithParseRes

func (client *RestClient) DoXmlWithParseRes(
	method string,
	resource string,
	queryArgs url.Values,
	headers map[string]string,
	bodyModel interface{},
	parseFunc func(res *http.Response) error) error

func (*RestClient) Endpoint

func (client *RestClient) Endpoint() string

func (*RestClient) GetWithModel

func (client *RestClient) GetWithModel(resource string, queryArgs url.Values, model interface{}) error

func (*RestClient) GetWithParseFunc

func (client *RestClient) GetWithParseFunc(resource string, queryArgs url.Values, parseFunc func(res *http.Response) error) error

func (*RestClient) NewRequest

func (client *RestClient) NewRequest(method, resource string, body io.Reader) (*http.Request, error)

func (*RestClient) NewRequestWithUrlQuery

func (client *RestClient) NewRequestWithUrlQuery(method, resource string, body io.Reader, queryArgs url.Values) (*http.Request, error)

func (*RestClient) PutWithParseFunc

func (client *RestClient) PutWithParseFunc(resource string, queryArgs url.Values, body io.Reader, parseFunc func(res *http.Response) error) error

func (*RestClient) SetDefaultProject

func (client *RestClient) SetDefaultProject(projectName string)

func (*RestClient) SetUserAgent

func (client *RestClient) SetUserAgent(userAgent string)

func (*RestClient) UserAgent

func (client *RestClient) UserAgent() string

Jump to

Keyboard shortcuts

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