request

package
v2.0.0-...-f0a18de Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 14 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugFunc

type DebugFunc func(data []byte)

DebugFunc Is an a function for debug request/response data

type Interface

type Interface interface {
	// Cancel Aborting request
	Cancel() Interface

	// Done Waiting for the request to finish
	Done() Interface

	// DoneWithContext Waiting for a request to complete, with the ability to interrupt the request through the context
	DoneWithContext(ctx context.Context) Interface

	// Error Return latest error
	Error() error

	// DebugFunc Set debug func and enable or disable debug mode
	// If fn=not nil - debug mode is enabled. If fn=nil, debug mode is disbled
	DebugFunc(fn DebugFunc) Interface

	// Request Returns the http.Request prepared for the request
	Request() (*http.Request, error)

	// Method Set request method
	Method(methods.Value) Interface

	// URL Set request URL
	URL(url string) Interface

	// Referer Setting the referer header
	Referer(referer string) Interface

	// UserAgent Setting the UserAgent Request Header
	UserAgent(userAgent string) Interface

	// ContentType Setting the Content-Type request header
	ContentType(contentType string) Interface

	// Accept Setting the Accept request header
	Accept(accept string) Interface

	// AcceptEncoding Setting the Accept-Encoding request header
	AcceptEncoding(acceptEncoding string) Interface

	// AcceptLanguage Setting the Accept-Language request header
	AcceptLanguage(acceptLanguage string) Interface

	// Settings the Accept-Charset request header
	AcceptCharset(acceptCharset string) Interface

	// Settings custom request header
	CustomHeader(name string, value string) Interface

	// BasicAuth Set login and password for request basic authorization
	BasicAuth(username string, password string) Interface

	// Cookies Adding cookies to the request
	Cookies(cookies []*http.Cookie) Interface

	// Header is an interface for custom headers manipulation
	Header() header.Interface

	// Latency is an request latency without reading body of response
	Latency() time.Duration

	// Response is an response interface
	Response() response.Interface

	// DataStream Data for the request body in the form of an interface of io.Reader
	DataStream(data io.Reader) Interface

	// DataString Data for the request body in the form of an string
	DataString(data string) Interface

	// DataString Data for the request body in the form of an []byte
	DataBytes(data []byte) Interface

	// DataJSON The data for the query is created by serializing the object in JSON
	DataJSON(data interface{}) Interface

	// DataXML The data for the query is created by serializing the object in XML
	DataXML(data interface{}) Interface

	// Do Executing the query and getting the result
	Do(client *http.Client) error
}

Interface is an request interface

type Pool

type Pool interface {
	// RequestGet Извлечение из pool нового элемента Request
	RequestGet() Interface

	// RequestPut Возврат в sync.Pool использованного элемента Request
	RequestPut(req Interface)
}

Pool is an interface of package

func New

func New() Pool

New creates a new object and return interface

type Request

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

Request is an Request implementation

func (*Request) Accept

func (r *Request) Accept(accept string) Interface

Accept Setting the Accept request header

func (*Request) AcceptCharset

func (r *Request) AcceptCharset(acceptCharset string) Interface

Settings the Accept-Charset request header

func (*Request) AcceptEncoding

func (r *Request) AcceptEncoding(acceptEncoding string) Interface

AcceptEncoding Setting the Accept-Encoding request header

func (*Request) AcceptLanguage

func (r *Request) AcceptLanguage(acceptLanguage string) Interface

AcceptLanguage Setting the Accept-Language request header

func (*Request) BasicAuth

func (r *Request) BasicAuth(username string, password string) Interface

BasicAuth Set login and password for request basic authorization

func (*Request) Cancel

func (r *Request) Cancel() Interface

Cancel Aborting request

func (*Request) ContentType

func (r *Request) ContentType(contentType string) Interface

ContentType Setting the Content-Type request header

func (*Request) Cookies

func (r *Request) Cookies(cookies []*http.Cookie) Interface

Cookies Adding cookies to the request

func (*Request) CustomHeader

func (r *Request) CustomHeader(name string, value string) Interface

Settings custom request header

func (*Request) DataBytes

func (r *Request) DataBytes(data []byte) Interface

DataBytes Data for the request body in the form of an []byte

func (*Request) DataJSON

func (r *Request) DataJSON(data interface{}) Interface

DataJSON The data for the query is created by serializing the object in JSON

func (*Request) DataStream

func (r *Request) DataStream(data io.Reader) Interface

DataStream Data for the request body in the form of an interface of io.Reader

func (*Request) DataString

func (r *Request) DataString(data string) Interface

DataString Data for the request body in the form of an string

func (*Request) DataXML

func (r *Request) DataXML(data interface{}) Interface

DataXML The data for the query is created by serializing the object in XML

func (*Request) DebugFunc

func (r *Request) DebugFunc(fn DebugFunc) Interface

DebugFunc Set debug func and enable or disable debug mode If fn=not nil - debug mode is enabled. If fn=nil, debug mode is disbled

func (*Request) Do

func (r *Request) Do(client *http.Client) error

Do Executing the query and getting the result

func (*Request) Done

func (r *Request) Done() Interface

Done Waiting for the request to finish

func (*Request) DoneWithContext

func (r *Request) DoneWithContext(ctx context.Context) Interface

DoneWithContext Waiting for a request to complete, with the ability to interrupt the request through the context

func (*Request) Error

func (r *Request) Error() error

Error Return latest error

func (*Request) Header

func (r *Request) Header() transportHeader.Interface

Header is an interface for custom headers manipulation

func (*Request) Latency

func (r *Request) Latency() time.Duration

Latency is an request latency without reading body of response

func (*Request) MakeRequest

func (r *Request) MakeRequest() (err error)

MakeRequest Создание запроса на основе метода запроса

func (*Request) Method

func (r *Request) Method(m methods.Value) Interface

Method Set request method

func (*Request) Referer

func (r *Request) Referer(referer string) Interface

Referer Setting the referer header

func (*Request) Request

func (r *Request) Request() (ret *http.Request, err error)

Request Returns the http.Request prepared for the request

func (*Request) Response

func (r *Request) Response() response.Interface

Response is an response interface

func (*Request) URL

func (r *Request) URL(url string) Interface

URL Set request URL

func (*Request) UserAgent

func (r *Request) UserAgent(userAgent string) Interface

UserAgent Setting the UserAgent request header

Jump to

Keyboard shortcuts

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