client

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiSpec

type ApiSpec interface {

	// IsCrypto indicates whether the API request uses EC-crypto.
	IsCrypto() bool

	// SetCryptoKey adds crypto key in parameters.
	SetCryptoKey(key string)

	// Url returns the request URL of API.
	Url() string

	// Payload returns the request body of API.
	Payload() Payload

	// Parse parses the response body.
	Parse(r io.Reader) (err error)
}

ApiSpec describes the specification of an 115 API.

type Body added in v0.7.4

type Body interface {
	io.ReadCloser

	// Size returns body size or -1 when unknown.
	Size() int64
}

type Client

type Client interface {

	// GetUserAgent returns current "User-Agent" value.
	GetUserAgent() string

	// ExportCookies exports cookies for specific URL.
	ExportCookies(url string) map[string]string

	// CallApi calls an API.
	CallApi(spec ApiSpec, context context.Context) error

	// Get performs an HTTP GET request.
	Get(
		url string, headers map[string]string, context context.Context,
	) (body Body, err error)

	// Post performs an HTTP POST request.
	Post(
		url string, payload Payload, headers map[string]string, context context.Context,
	) (body Body, err error)
}

Client is the low-level client which executes ApiSpec.

type Payload

type Payload interface {
	io.Reader

	// ContentType returns the MIME type of payload.
	ContentType() string

	// ContentLength returns the size in bytes of payload.
	ContentLength() int64
}

Payload describes the request body.

Jump to

Keyboard shortcuts

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