net

package
v0.0.0-...-8e26d1b Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TAG = "RockHttp"

Variables

View Source
var HttpClient = NewRockHttpClient()

Functions

This section is empty.

Types

type RockHttp

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

func NewRockHttpClient

func NewRockHttpClient() *RockHttp

func (*RockHttp) Do

func (rockhttp *RockHttp) Do(ctx context.Context, url string, method string, header *http.Header, body io.Reader) (*http.Response, error)

func (*RockHttp) DoRequest

func (rockhttp *RockHttp) DoRequest(req *http.Request) (*http.Response, error)

func (*RockHttp) DoResBytes

func (rockhttp *RockHttp) DoResBytes(req *http.Request) ([]byte, error)

读取response.Body 的bytes

func (*RockHttp) DoResJson

func (rockhttp *RockHttp) DoResJson(req *http.Request, obj any) error

结果json格式的bytes 转为 指定对象

func (*RockHttp) DoResProtoJson

func (rockhttp *RockHttp) DoResProtoJson(req *http.Request, message proto.Message) error

json格式的bytes 转为 proto-Message

func (*RockHttp) DoResProtoMessage

func (rockhttp *RockHttp) DoResProtoMessage(req *http.Request, message *proto.Message) error

结果proto格式的bytes 转为 proto-Message

func (*RockHttp) Get

func (rockhttp *RockHttp) Get(ctx context.Context, url string, header *http.Header) ([]byte, error)

func (*RockHttp) GetResponse

func (rockhttp *RockHttp) GetResponse(ctx context.Context, url string, header *http.Header) (*http.Response, error)

func (*RockHttp) PostForm

func (rockhttp *RockHttp) PostForm(ctx context.Context, url string, data url.Values, headerArg *http.Header) ([]byte, error)

func (*RockHttp) UploadFile

func (rockhttp *RockHttp) UploadFile(ctx context.Context, url string, method string, header *http.Header, fileFieldName, itemFilepath, fileName string) (*http.Response, error)

上传文件

func (*RockHttp) UploadFileResBytes

func (rockhttp *RockHttp) UploadFileResBytes(ctx context.Context, url string, method string, header *http.Header, fileFieldName, itemFilepath, fileName string) ([]byte, error)

上传文件,结果转为 bytes

Jump to

Keyboard shortcuts

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