goo_http_request

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CONTENT_TYPE_XML  = "application/xml"
	CONTENT_TYPE_JSON = "application/json"
	CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func Get

func Get(url string) ([]byte, error)

func Post

func Post(url string, data []byte) ([]byte, error)

func PostJson

func PostJson(url string, data []byte) ([]byte, error)

func Put

func Put(url string, data []byte) ([]byte, error)

func Upload

func Upload(url, fileField, fileName string, f io.Reader, data map[string]string) (b []byte, err error)

Types

type Option

type Option struct {
	Name  string
	Value interface{}
}

func ContentTypeFormOption

func ContentTypeFormOption() Option

func ContentTypeJsonOption

func ContentTypeJsonOption() Option

func ContentTypeXmlOption

func ContentTypeXmlOption() Option

func DebugOption

func DebugOption() Option

func HeaderOption

func HeaderOption(field, value string) Option

func TlsOption

func TlsOption(caCrtFile, clientCrtFile, clientKeyFile string) Option

type Request

type Request struct {
	Headers map[string]string
	Tls     *Tls
	// contains filtered or unexported fields
}

func Debug added in v1.0.18

func Debug() *Request

func New

func New(opts ...Option) *Request

func SetHeader added in v1.0.18

func SetHeader(name, value string) *Request

func (*Request) Debug

func (r *Request) Debug() *Request

func (*Request) Do

func (r *Request) Do(method, url string, body io.Reader) ([]byte, error)

func (*Request) Get

func (r *Request) Get(url string) ([]byte, error)

func (*Request) JsonContentType

func (r *Request) JsonContentType() *Request

func (*Request) Post

func (r *Request) Post(url string, data []byte) ([]byte, error)

func (*Request) PostJson added in v1.0.19

func (r *Request) PostJson(url string, data []byte) ([]byte, error)

func (*Request) Put

func (r *Request) Put(url string, data []byte) ([]byte, error)

func (*Request) SetContentType

func (r *Request) SetContentType(contentType string) *Request

func (*Request) SetHeader added in v1.0.18

func (r *Request) SetHeader(name, value string) *Request

func (*Request) SetTimeout added in v1.0.3

func (r *Request) SetTimeout(d time.Duration) *Request

func (*Request) Upload added in v1.0.6

func (r *Request) Upload(url, fileField, fileName string, f io.Reader, data map[string]string) (b []byte, err error)

type Tls

type Tls struct {
	CaCrtFile     string
	ClientCrtFile string
	ClientKeyFile string
}

func (*Tls) CaCrt

func (this *Tls) CaCrt() []byte

func (*Tls) ClientCrt

func (this *Tls) ClientCrt() tls.Certificate

Jump to

Keyboard shortcuts

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