https

package
v0.0.0-...-e67ccf8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidUrl     = errors.New("url must start with 'http'")
	ErrInvalidEncoder = errors.New("invalid encoder")
)

Functions

func Get

func Get(client *http.Client, url string) ([]byte, error)

Get 发起http get请求

func GetWithObj

func GetWithObj(client *http.Client, url string, encoder serialize.Codec, obj interface{}) error

GetWithObj 发起get请求,并将结果反序列化到指定obj中

func Post

func Post(client *http.Client, url string, contentType string, body io.Reader) ([]byte, error)

Post 发起POST请求

func PostWithObj

func PostWithObj(client *http.Client, url string, contentType string, body io.Reader, encoder serialize.Codec, v interface{}) error

PostWithObj 发起POST请求并将结果发序列化到指定obj

Types

type TLSClient

type TLSClient struct {
	// contains filtered or unexported fields
}

func NewTLSClient

func NewTLSClient(caCrt, clientCrt, clientKey string, encoder serialize.Codec) *TLSClient

NewTLSClient 创建TLS客户端

func (*TLSClient) Get

func (h *TLSClient) Get(url string) ([]byte, error)

Get GET请求

func (*TLSClient) GetWithObj

func (h *TLSClient) GetWithObj(url string, obj interface{}) error

GetWithObj GET并反序列化

func (*TLSClient) ListenAndServeTLS

func (h *TLSClient) ListenAndServeTLS(serverCrt, serverKey string) error

ListenAndServeTLS start

func (*TLSClient) Post

func (h *TLSClient) Post(url, contentType string, body io.Reader) ([]byte, error)

Post POST请求

func (*TLSClient) PostWithObj

func (h *TLSClient) PostWithObj(url, contentType string, body io.Reader, obj interface{}) error

PostWithObj POST请求并反序列化

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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