http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout      = 5 // 默认超时时间,单位秒
	MaxIdleConns        = 20
	MaxIdleConnsPerHost = 10
)

Variables

This section is empty.

Functions

func DoGet

func DoGet(url string) (string, error)

func DoGetWithHeader

func DoGetWithHeader(url string, header map[string]string) (string, error)

func DoPost

func DoPost(url, body string) (string, error)

func DoPostWithHeader

func DoPostWithHeader(url, body string, header map[string]string) (string, error)

Types

type Client

type Client struct {
	Client  *http.Client
	Timeout int // 超时时间,单位秒
}
var DefaultClient *Client

func NewClient

func NewClient(maxIdleConns, maxIdleConnsPerHost int) *Client

func (*Client) DoRequestWithHeader

func (p *Client) DoRequestWithHeader(url, method, body string, header map[string]string) (string, error)

DoRequestWithHeader method 支持GET, POST等方式,应该传常量,而不是直接传字符串,参考http.MethodGet timeout 超时时间,单位秒

Jump to

Keyboard shortcuts

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