bzreq

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GET     = method{/* contains filtered or unexported fields */}
	POST    = method{/* contains filtered or unexported fields */}
	PUT     = method{/* contains filtered or unexported fields */}
	DELETE  = method{/* contains filtered or unexported fields */}
	HEAD    = method{/* contains filtered or unexported fields */}
	PATCH   = method{/* contains filtered or unexported fields */}
	CONNECT = method{/* contains filtered or unexported fields */}
	OPTIONS = method{/* contains filtered or unexported fields */}
	TRACE   = method{/* contains filtered or unexported fields */}
)
View Source
var (
	JsonHeader     = HeaderOption{Key: "Content-Type", Value: "application/json;charset=UTF-8"}
	FormHeader     = HeaderOption{Key: "Content-Type", Value: "application/x-www-form-urlencoded"}
	FormDataHeader = HeaderOption{Key: "Content-Type", Value: "multipart/form-data"}
	HtmlHeader     = HeaderOption{Key: "Content-Type", Value: "text/html;charset=utf-8"}
	JsHeader       = HeaderOption{Key: "Content-Type", Value: "text/javascript;charset=utf-8"}
	JsxHeader      = HeaderOption{Key: "Content-Type", Value: "application/x-javascript"}
	CssHeader      = HeaderOption{Key: "Content-Type", Value: "text/css;charset=utf-8"}

	JpegHeader = HeaderOption{Key: "Content-Type", Value: "image/jpeg"}
	GifHeader  = HeaderOption{Key: "Content-Type", Value: "image/gif"}
	PngHeader  = HeaderOption{Key: "Content-Type", Value: "image/png"}
	SvgHeader  = HeaderOption{Key: "Content-Type", Value: "image/svg+xml"}
)

Functions

func DownloadHttpResult

func DownloadHttpResult(url, filePath string, timeout time.Duration) error

DownloadHttpResult 存储网络资源

func Get

func Get(url string, data []byte, timeout time.Duration, headers ...HeaderOption) ([]byte, error)

func GetAny

func GetAny(url string, data []byte, timeout time.Duration, v any, headers ...HeaderOption) error

func GetHttpResult

func GetHttpResult(url string, timeout time.Duration) ([]byte, error)

GetHttpResult 获取网络资源

func GetResponse added in v0.0.4

func GetResponse(url string, data []byte, timeout time.Duration, headers ...HeaderOption) (*http.Response, error)

func GetString

func GetString(url string, data []byte, timeout time.Duration, headers ...HeaderOption) (string, error)

func PostForm

func PostForm(url string, data map[string]string, urlEncode bool, timeout time.Duration, headers ...HeaderOption) ([]byte, error)

func PostFormAny

func PostFormAny(url string, data map[string]string, timeout time.Duration, v any, headers ...HeaderOption) error

func PostFormString

func PostFormString(url string, data map[string]string, timeout time.Duration, headers ...HeaderOption) (string, error)

func PostJson

func PostJson(url string, data []byte, timeout time.Duration, headers ...HeaderOption) ([]byte, error)

func PostJsonAny

func PostJsonAny(url string, data []byte, timeout time.Duration, v any, headers ...HeaderOption) error

func PostJsonString

func PostJsonString(url string, data []byte, timeout time.Duration, headers ...HeaderOption) (string, error)

Types

type Curl

type Curl struct {
	Err error
	// contains filtered or unexported fields
}

func New

func New(method method, url string, data []byte) *Curl

func (*Curl) Close

func (c *Curl) Close() error

func (*Curl) Debug

func (c *Curl) Debug()

func (*Curl) Response added in v0.0.4

func (c *Curl) Response(t time.Duration) (*http.Response, error)

func (*Curl) Result

func (c *Curl) Result(t time.Duration) ([]byte, error)

func (*Curl) ResultAny

func (c *Curl) ResultAny(t time.Duration, v any) error

func (*Curl) ResultString

func (c *Curl) ResultString(t time.Duration) (string, error)

func (*Curl) SetHeader

func (c *Curl) SetHeader(headers ...HeaderOption) *Curl

type HeaderOption

type HeaderOption struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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