request

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package request http request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultRequest

type DefaultRequest struct {
}

DefaultRequest 默认请求

func NewDefaultRequest

func NewDefaultRequest() *DefaultRequest

NewDefaultRequest 实例化

func (*DefaultRequest) Get

func (srv *DefaultRequest) Get(ctx context.Context, url string) ([]byte, error)

Get http get request

func (*DefaultRequest) Post

func (srv *DefaultRequest) Post(ctx context.Context, url string, data []byte) ([]byte, error)

Post http post request

func (*DefaultRequest) PostFile

func (srv *DefaultRequest) PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)

PostFile http post file request

func (*DefaultRequest) PostJSON

func (srv *DefaultRequest) PostJSON(ctx context.Context, url string, data any) ([]byte, error)

PostJSON http post json request

func (*DefaultRequest) PostJSONWithRespContentType

func (srv *DefaultRequest) PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)

PostJSONWithRespContentType http post json request with the response content type

func (*DefaultRequest) PostMultipartForm

func (srv *DefaultRequest) PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) (resp []byte, err error)

PostMultipartForm http post multipart form request

func (*DefaultRequest) PostXML added in v0.0.3

func (srv *DefaultRequest) PostXML(ctx context.Context, url string, data any) ([]byte, error)

PostXML perform the HTTP/POST request with XML body

func (*DefaultRequest) PostXMLWithTLS added in v0.0.4

func (srv *DefaultRequest) PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)

PostXMLWithTLS perform the HTTP/POST request with XML body and TLS

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool   `json:"isFile"`
	Value     []byte `json:"value"`
	FieldName string `json:"fieldName"`
	FileName  string `json:"fileName"`
}

MultipartFormField multipart form field

type Request

type Request interface {
	Get(ctx context.Context, url string) ([]byte, error)
	Post(ctx context.Context, url string, data []byte) ([]byte, error)
	PostJSON(ctx context.Context, url string, data any) ([]byte, error)
	PostJSONWithRespContentType(ctx context.Context, url string, data any) ([]byte, string, error)
	PostFile(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
	PostMultipartForm(ctx context.Context, url string, files []MultipartFormField) ([]byte, error)
	PostXML(ctx context.Context, url string, data any) ([]byte, error)
	PostXMLWithTLS(ctx context.Context, url string, data any, ca, key string) ([]byte, error)
}

Request http request interface

Jump to

Keyboard shortcuts

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