requtil

package
v0.0.0-...-308a713 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 11 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, retry *RestyRetry) *resty.Client

func NewLongConnTransport

func NewLongConnTransport() *http.Transport

func RequestLongConn

func RequestLongConn(
	client *resty.Client, req *Req,
) (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 RestyRetry

type RestyRetry struct {
	Attempts   uint
	Wait       time.Duration
	MaxWait    time.Duration
	RetryAfter resty.RetryAfterFunc
}

Jump to

Keyboard shortcuts

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