requtil

package
v0.0.0-...-3f39334 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodUnknown = iota
	POST
	GET
)
View Source
const (
	TypeJSON       = "json"
	TypeXML        = "xml"
	TypeUrlencoded = "urlencoded"
	TypeForm       = "form"
	TypeFormData   = "form-data"
	TypeHTML       = "html"
	TypeText       = "text"
	TypeMultipart  = "multipart"
)

Variables

This section is empty.

Functions

func Init

func Init(loggerIns Logger)

func NewLongConnClient

func NewLongConnClient(timeout time.Duration) *resty.Client

func NewLongConnTransport

func NewLongConnTransport() *http.Transport

func RequestLongConn

func RequestLongConn(
	client *resty.Client, req *Req, retrySettings *RetrySettings,
) (httpCode int, resp []byte, err error)

Types

type DullLogger

type DullLogger struct{}

func (*DullLogger) Errorf

func (l *DullLogger) Errorf(format string, args ...interface{})

func (*DullLogger) Infof

func (l *DullLogger) Infof(format string, args ...interface{})

func (*DullLogger) Warningf

func (l *DullLogger) Warningf(format string, args ...interface{})

type Logger

type Logger interface {
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
}

type Method

type Method int

type Req

type Req struct {
	ApiName    string
	Url        string
	Method     Method
	TargetType string

	FileName  string // for file request
	Query     map[string]string
	Body      interface{}
	Headers   map[string]string
	Cookies   []*http.Cookie
	RequestId string

	TimeOut     time.Duration
	RateLimiter *rate.Limiter
	RespCheck   func(content []byte) (err error)
}

type RetrySettings

type RetrySettings struct {
	Attempts        uint
	Delay           time.Duration
	OnRetryCallback func(attemptNum uint, err error)
}

Jump to

Keyboard shortcuts

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