shared

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeAppJSON = "application/json"
	ContentTypeAppXML  = "application/xml"
)
View Source
const (
	HeaderAzureAsync        = "Azure-AsyncOperation"
	HeaderContentLength     = "Content-Length"
	HeaderContentType       = "Content-Type"
	HeaderLocation          = "Location"
	HeaderOperationLocation = "Operation-Location"
	HeaderRetryAfter        = "Retry-After"
	HeaderUserAgent         = "User-Agent"
)
View Source
const (
	// Module is the name of the calling module used in telemetry data.
	Module = "azcore"

	// Version is the semantic version (see http://semver.org) of this module.
	Version = "v0.19.0"
)
View Source
const (
	DefaultMaxRetries = 3
)

Variables

View Source
var ErrNoBody = errors.New("the response did not contain a body")

ErrNoBody is returned if the response didn't contain a body.

Functions

func Delay

func Delay(ctx context.Context, delay time.Duration) error

Delay waits for the duration to elapse or the context to be cancelled.

func EndpointToScope

func EndpointToScope(endpoint string) string

EndpointToScope converts the provided URL endpoint to its default scope.

func GetJSON

func GetJSON(resp *http.Response) (map[string]interface{}, error)

GetJSON reads the response body into a raw JSON object. It returns ErrNoBody if there was no content.

func HasStatusCode

func HasStatusCode(resp *http.Response, statusCodes ...int) bool

HasStatusCode returns true if the Response's status code is one of the specified values.

func NewResponseError

func NewResponseError(inner error, resp *http.Response) error

func NopCloser

func NopCloser(rs io.ReadSeeker) io.ReadSeekCloser

NopCloser returns a ReadSeekCloser with a no-op close method wrapping the provided io.ReadSeeker.

func RetryAfter

func RetryAfter(resp *http.Response) time.Duration

RetryAfter returns non-zero if the response contains a Retry-After header value.

Types

type BodyDownloadPolicyOpValues

type BodyDownloadPolicyOpValues struct {
	Skip bool
}

BodyDownloadPolicyOpValues is the struct containing the per-operation values

type CtxWithHTTPHeaderKey

type CtxWithHTTPHeaderKey struct{}

CtxWithHTTPHeaderKey is used as a context key for adding/retrieving http.Header.

type CtxWithRetryOptionsKey

type CtxWithRetryOptionsKey struct{}

CtxWithRetryOptionsKey is used as a context key for adding/retrieving RetryOptions.

type ResponseError

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

func (*ResponseError) Error

func (e *ResponseError) Error() string

Error implements the error interface for type ResponseError.

func (*ResponseError) NonRetriable

func (e *ResponseError) NonRetriable()

NonRetriable indicates this error is non-transient.

func (*ResponseError) RawResponse

func (e *ResponseError) RawResponse() *http.Response

RawResponse returns the HTTP response associated with this error.

func (*ResponseError) Unwrap

func (e *ResponseError) Unwrap() error

Unwrap returns the inner error.

Jump to

Keyboard shortcuts

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