Documentation
¶
Index ¶
- Constants
- Variables
- func BasicAuthorization(user, password string) string
- func BearerAuthorization(token string) string
- type Content
- func (content Content) Decrypt(algorithm CryptoAlgorithm, key []byte) (*Content, error)
- func (content Content) DecryptWithAESCTR(key []byte) (*Content, error)
- func (content Content) Encrypt(algorithm CryptoAlgorithm, key []byte) (*Content, error)
- func (content Content) EncryptWithAESCTR(key []byte) (*Content, error)
- func (content Content) LogString(maxSize uint64) string
- func (content Content) MarshalJSON() ([]byte, error)
- func (content *Content) ReadCloser() io.ReadCloser
- func (content *Content) Reader() io.Reader
- func (content Content) UnmarshalContentJSON(v interface{}) (err error)
- func (content *Content) UnmarshalJSON(payload []byte) error
- type CryptoAlgorithm
- type Options
- type ProgressBarMaxChanger
- type ProgressBarMaxSetter
Constants ¶
const DefaultAttempts = 5
DefaultAttempts defines the number of attempts for requests by default
const DefaultInterAttemptBackoffInterval = 5 * time.Minute
DefaultInterAttemptBackoffInterval defines the interval between 2 inter attempt delay increases
const DefaultInterAttemptDelay = 3 * time.Second
DefaultInterAttemptDelay defines the sleep delay between 2 attempts during the first backoff interval
const DefaultRequestBodyLogSize = 2048
DefaultRequestBodyLogSize defines the maximum size of the request body that should be logged
const DefaultResponseBodyLogSize = 2048
DefaultResponseBodyLogSize defines the maximum size of the response body that should be logged
const DefaultTimeout = 2 * time.Second
DefaultTimeout defines the timeout for a request
Variables ¶
var VERSION = "0.9.16" + commit
VERSION is the version of this library
Functions ¶
func BasicAuthorization ¶ added in v0.2.0
BasicAuthorization builds a basic authorization string
func BearerAuthorization ¶ added in v0.2.0
BearerAuthorization builds a Token authorization string
Types ¶
type Content ¶
type Content struct { Type string `json:"Type"` StatusCode int `json:"StatusCode,omitempty"` Status string `json:"Status,omitempty"` Name string `json:"Name,omitempty"` URL *url.URL `json:"-"` Length uint64 `json:"Length"` Data []byte `json:"Data"` Headers http.Header `json:"headers,omitempty"` Cookies []*http.Cookie `json:"-"` }
Content defines some content
func ContentFromReader ¶
ContentFromReader instantiates a Content from an I/O reader
func ContentWithData ¶
ContentWithData instantiates a Content from a simple byte array
func (Content) Decrypt ¶ added in v0.7.1
func (content Content) Decrypt(algorithm CryptoAlgorithm, key []byte) (*Content, error)
func (Content) DecryptWithAESCTR ¶ added in v0.7.1
func (Content) Encrypt ¶ added in v0.7.1
func (content Content) Encrypt(algorithm CryptoAlgorithm, key []byte) (*Content, error)
func (Content) EncryptWithAESCTR ¶ added in v0.7.1
func (Content) MarshalJSON ¶ added in v0.6.1
MarshalJSON marshals the Content into JSON
implements json.Marshaler
func (*Content) ReadCloser ¶ added in v0.5.0
func (content *Content) ReadCloser() io.ReadCloser
ReadCloser gets an io.ReadCloser from this Content
func (Content) UnmarshalContentJSON ¶ added in v0.5.0
UnmarshalContentJSON unmarshals its Data into JSON
func (*Content) UnmarshalJSON ¶ added in v0.6.1
UnmarshalJSON unmarshals the Content from JSON
implements json.Unmarshaler
type CryptoAlgorithm ¶ added in v0.7.1
type CryptoAlgorithm uint
const ( NONE CryptoAlgorithm = iota AESCTR )
func CryptoAlgorithmFromString ¶ added in v0.7.2
func CryptoAlgorithmFromString(algorithm string) (CryptoAlgorithm, error)
func (CryptoAlgorithm) MarshalJSON ¶ added in v0.7.2
func (algorithm CryptoAlgorithm) MarshalJSON() ([]byte, error)
func (CryptoAlgorithm) String ¶ added in v0.7.1
func (algorithm CryptoAlgorithm) String() string
func (*CryptoAlgorithm) UnmarshalJSON ¶ added in v0.7.2
func (algorithm *CryptoAlgorithm) UnmarshalJSON(data []byte) (err error)
type Options ¶
type Options struct { Context context.Context Method string URL *url.URL Proxy *url.URL Headers map[string]string Cookies []*http.Cookie Parameters map[string]string Accept string PayloadType string // if not provided, it is computed. See https://gihub.com/gildas/go-request#payload Payload interface{} // See https://gihub.com/gildas/go-request#payload AttachmentType string // MIME type of the attachment Attachment io.Reader // binary data that should be attached to the paylod (e.g.: multipart forms) Authorization string RequestID string UserAgent string Transport *http.Transport ProgressWriter io.Writer // if not nil, the progress of the request will be written to this writer ProgressSetMaxFunc func(int64) RetryableStatusCodes []int // Status codes that should be retried, by default: 429, 502, 503, 504 Attempts uint // number of attempts, by default: 5 InterAttemptDelay time.Duration // how long to wait between 2 attempts during the first backoff interval, by default: 3s InterAttemptBackoffInterval time.Duration // how often the inter attempt delay should be increased, by default: 5 minutes InterAttemptUseRetryAfter bool // if true, the Retry-After header will be used to wait between 2 attempts, otherwise an exponential backoff will be used, by default: false Timeout time.Duration RequestBodyLogSize int // how many characters of the request body should be logged, if possible (<0 => nothing logged) ResponseBodyLogSize int // how many characters of the response body should be logged (<0 => nothing logged) Logger *logger.Logger }
Options defines options of an HTTP request
type ProgressBarMaxChanger ¶ added in v0.9.0
type ProgressBarMaxChanger interface {
ChangeMax64(int64)
}
ProgressBarMaxChanger is an interface that allows setting the maximum value of a progress bar
This interface allows packages such as "/github.com/schollz/progressbar/v3" to be used as progress bars
type ProgressBarMaxSetter ¶ added in v0.9.0
type ProgressBarMaxSetter interface {
SetMax64(int64)
}
ProgressBarMaxSetter is an interface that allows setting the maximum value of a progress bar