requests

package
v1.7.13 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultH2CClient *http.Client
)
View Source
var (
	DefaultHttpClient *http.Client
)
View Source
var Marshal func(v interface{}) ([]byte, error)
View Source
var Unmarshal func(data []byte, v interface{}) error

Functions

func InstallPrometheus

func InstallPrometheus(serviceName string, p prom)

func NewH2cClient

func NewH2cClient(rwTimeout time.Duration, connectTimeout ...time.Duration)

Newh2cClient .

func NewHttpClient

func NewHttpClient(rwTimeout time.Duration, connectTimeout ...time.Duration)

Newhttpclient .

func UseMiddleware

func UseMiddleware(handle ...Handler)

Types

type H2CRequest

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

H2CRequest .

func (*H2CRequest) AddHeader added in v1.6.9

func (h2cReq *H2CRequest) AddHeader(key, value string) Request

AddHeader .

func (*H2CRequest) Delete

func (h2cReq *H2CRequest) Delete() Request

Delete .

func (*H2CRequest) Get

func (h2cReq *H2CRequest) Get() Request

Get .

func (*H2CRequest) GetRequest

func (h2cReq *H2CRequest) GetRequest() *http.Request

func (*H2CRequest) GetRespone

func (h2cReq *H2CRequest) GetRespone() (*http.Response, error)

func (*H2CRequest) Head

func (h2cReq *H2CRequest) Head() Request

Head .

func (*H2CRequest) Next

func (h2cReq *H2CRequest) Next()

func (*H2CRequest) Post

func (h2cReq *H2CRequest) Post() Request

Post .

func (*H2CRequest) Put

func (h2cReq *H2CRequest) Put() Request

Put .

func (*H2CRequest) SetBody

func (h2cReq *H2CRequest) SetBody(byts []byte) Request

SetBody .

func (*H2CRequest) SetHeader

func (h2cReq *H2CRequest) SetHeader(header http.Header) Request

SetHeader .

func (*H2CRequest) SetJSONBody

func (h2cReq *H2CRequest) SetJSONBody(obj interface{}) Request

SetJSONBody .

func (*H2CRequest) SetParam

func (h2cReq *H2CRequest) SetParam(key string, value interface{}) Request

SetParam .

func (*H2CRequest) Singleflight

func (h2cReq *H2CRequest) Singleflight(key ...interface{}) Request

func (*H2CRequest) Stop

func (h2cReq *H2CRequest) Stop(e ...error)

func (*H2CRequest) ToBytes

func (h2cReq *H2CRequest) ToBytes() (value []byte, r Response)

ToBytes .

func (*H2CRequest) ToJSON

func (h2cReq *H2CRequest) ToJSON(obj interface{}) (r Response)

ToJSON .

func (*H2CRequest) ToString

func (h2cReq *H2CRequest) ToString() (value string, r Response)

ToString .

func (*H2CRequest) ToXML

func (h2cReq *H2CRequest) ToXML(v interface{}) (r Response)

ToXML .

func (*H2CRequest) URL

func (h2cReq *H2CRequest) URL() string

URI .

func (*H2CRequest) WithContext added in v1.7.2

func (h2cReq *H2CRequest) WithContext(ctx context.Context) Request

WithContext .

type Handler

type Handler func(Middleware)

type HttpRequest

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

HttpRequest .

func (*HttpRequest) AddHeader added in v1.6.9

func (req *HttpRequest) AddHeader(key, value string) Request

AddHeader .

func (*HttpRequest) Delete

func (req *HttpRequest) Delete() Request

Delete .

func (*HttpRequest) Get

func (req *HttpRequest) Get() Request

Get .

func (*HttpRequest) GetRequest

func (req *HttpRequest) GetRequest() *http.Request

func (*HttpRequest) GetRespone

func (req *HttpRequest) GetRespone() (*http.Response, error)

func (*HttpRequest) Head

func (req *HttpRequest) Head() Request

Head .

func (*HttpRequest) Next

func (req *HttpRequest) Next()

func (*HttpRequest) Post

func (req *HttpRequest) Post() Request

Post .

func (*HttpRequest) Put

func (req *HttpRequest) Put() Request

Put .

func (*HttpRequest) SetBody

func (req *HttpRequest) SetBody(byts []byte) Request

SetBody .

func (*HttpRequest) SetHeader

func (req *HttpRequest) SetHeader(header http.Header) Request

SetHeader .

func (*HttpRequest) SetJSONBody

func (req *HttpRequest) SetJSONBody(obj interface{}) Request

SetJSONBody .

func (*HttpRequest) SetParam

func (req *HttpRequest) SetParam(key string, value interface{}) Request

SetParam .

func (*HttpRequest) Singleflight

func (req *HttpRequest) Singleflight(key ...interface{}) Request

func (*HttpRequest) Stop

func (req *HttpRequest) Stop(e ...error)

func (*HttpRequest) ToBytes

func (req *HttpRequest) ToBytes() (value []byte, r Response)

ToBytes .

func (*HttpRequest) ToJSON

func (req *HttpRequest) ToJSON(obj interface{}) (r Response)

ToJSON .

func (*HttpRequest) ToString

func (req *HttpRequest) ToString() (value string, r Response)

ToString .

func (*HttpRequest) ToXML

func (req *HttpRequest) ToXML(v interface{}) (r Response)

ToXML .

func (*HttpRequest) URL

func (req *HttpRequest) URL() string

URI .

func (*HttpRequest) WithContext added in v1.7.2

func (req *HttpRequest) WithContext(ctx context.Context) Request

WithContext .

type Middleware

type Middleware interface {
	Next()
	Stop(...error)
	GetRequest() *http.Request
	GetRespone() (*http.Response, error)
	// contains filtered or unexported methods
}

type Request

type Request interface {
	Post() Request
	Put() Request
	Get() Request
	Delete() Request
	Head() Request
	SetJSONBody(obj interface{}) Request
	SetBody(byts []byte) Request
	ToJSON(obj interface{}) Response
	ToString() (string, Response)
	ToBytes() ([]byte, Response)
	ToXML(v interface{}) Response
	SetParam(key string, value interface{}) Request
	URL() string
	WithContext(context.Context) Request
	Singleflight(key ...interface{}) Request
	SetHeader(header http.Header) Request
	AddHeader(key, value string) Request
}

Request .

func NewH2CRequest

func NewH2CRequest(rawurl string) Request

func NewHttpRequest

func NewHttpRequest(rawurl string) Request

type Response

type Response struct {
	Error         error
	Header        http.Header
	ContentLength int64
	ContentType   string
	StatusCode    int
	HTTP11        bool
}

Response .

Jump to

Keyboard shortcuts

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