requests

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Marshal func(v interface{}) ([]byte, error)
View Source
var PrometheusImpl prometheus
View Source
var Unmarshal func(data []byte, v interface{}) error

Functions

func NewH2cClient added in v1.5.5

func NewH2cClient(rwTimeout time.Duration)

Newh2cClient .

func NewHttpClient added in v1.5.5

func NewHttpClient(rwTimeout time.Duration)

Newhttpclient .

Types

type Group added in v1.5.6

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

Group represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.

func (*Group) Do added in v1.5.6

func (g *Group) Do(key string, fn func() (interface{}, error)) (v interface{}, err error, shared bool)

Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results. The return value shared indicates whether v was given to multiple callers.

func (*Group) DoChan added in v1.5.6

func (g *Group) DoChan(key string, fn func() (interface{}, error)) <-chan Result

DoChan is like Do but returns a channel that will receive the results when they are ready.

func (*Group) Forget added in v1.5.6

func (g *Group) Forget(key string)

Forget tells the singleflight to forget about a key. Future calls to Do for this key will call the function rather than waiting for an earlier call to complete.

type H2CRequest

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

H2CRequest .

func (*H2CRequest) Delete

func (hr *H2CRequest) Delete() Request

Delete .

func (*H2CRequest) Get

func (hr *H2CRequest) Get() Request

Get .

func (*H2CRequest) Head added in v1.5.5

func (hr *H2CRequest) Head() Request

Head .

func (*H2CRequest) Post

func (hr *H2CRequest) Post() Request

Post .

func (*H2CRequest) Put

func (hr *H2CRequest) Put() Request

Put .

func (*H2CRequest) SetBody

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

SetBody .

func (*H2CRequest) SetContext added in v1.3.1

func (hr *H2CRequest) SetContext(ctx context.Context) Request

SetContext .

func (*H2CRequest) SetHeader

func (hr *H2CRequest) SetHeader(key, value string) Request

SetHeader .

func (*H2CRequest) SetJSONBody

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

SetJSONBody .

func (*H2CRequest) SetParam

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

SetParam .

func (*H2CRequest) Singleflight added in v1.5.6

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

func (*H2CRequest) ToBytes

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

ToBytes .

func (*H2CRequest) ToJSON

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

ToJSON .

func (*H2CRequest) ToString

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

ToString .

func (*H2CRequest) ToXML

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

ToXML .

func (*H2CRequest) URI

func (hr *H2CRequest) URI() string

URI .

type HttpRequest added in v1.5.5

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

HttpRequest .

func (*HttpRequest) Delete added in v1.5.5

func (hr *HttpRequest) Delete() Request

Delete .

func (*HttpRequest) Get added in v1.5.5

func (hr *HttpRequest) Get() Request

Get .

func (*HttpRequest) Head added in v1.5.5

func (hr *HttpRequest) Head() Request

Head .

func (*HttpRequest) Post added in v1.5.5

func (hr *HttpRequest) Post() Request

Post .

func (*HttpRequest) Put added in v1.5.5

func (hr *HttpRequest) Put() Request

Put .

func (*HttpRequest) SetBody added in v1.5.5

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

SetBody .

func (*HttpRequest) SetContext added in v1.5.5

func (hr *HttpRequest) SetContext(ctx context.Context) Request

SetContext .

func (*HttpRequest) SetHeader added in v1.5.5

func (hr *HttpRequest) SetHeader(key, value string) Request

SetHeader .

func (*HttpRequest) SetJSONBody added in v1.5.5

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

SetJSONBody .

func (*HttpRequest) SetParam added in v1.5.5

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

SetParam .

func (*HttpRequest) Singleflight added in v1.5.6

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

func (*HttpRequest) ToBytes added in v1.5.5

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

ToBytes .

func (*HttpRequest) ToJSON added in v1.5.5

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

ToJSON .

func (*HttpRequest) ToString added in v1.5.5

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

ToString .

func (*HttpRequest) ToXML added in v1.5.5

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

ToXML .

func (*HttpRequest) URI added in v1.5.5

func (hr *HttpRequest) URI() string

URI .

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
	SetHeader(key, value string) Request
	SetParam(key string, value interface{}) Request
	URI() string
	SetContext(context.Context) Request
	Singleflight(key ...interface{}) Request
}

Request .

func NewH2CRequest

func NewH2CRequest(rawurl string) Request

func NewHttpRequest added in v1.5.5

func NewHttpRequest(rawurl string) Request

type Response

type Response struct {
	Error         error
	Header        map[string]string
	ContentLength int64
	ContentType   string
	StatusCode    int
	HTTP11        bool
}

Response .

type Result added in v1.5.6

type Result struct {
	Val    interface{}
	Err    error
	Shared bool
}

Result holds the results of Do, so they can be passed on a channel.

Jump to

Keyboard shortcuts

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