package shared
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/shared"
Index ¶
- Constants
- Variables
- func Delay(ctx context.Context, delay time.Duration) error
- func EndpointToScope(endpoint string) string
- func GetJSON(resp *http.Response) (map[string]interface{}, error)
- func HasStatusCode(resp *http.Response, statusCodes ...int) bool
- func NewResponseError(inner error, resp *http.Response) error
- func NopCloser(rs io.ReadSeeker) io.ReadSeekCloser
- func RetryAfter(resp *http.Response) time.Duration
- type AcquireResource
- type BodyDownloadPolicyOpValues
- type CtxWithHTTPHeaderKey
- type CtxWithRetryOptionsKey
- type ExpiringResource
- func NewExpiringResource(ar AcquireResource) *ExpiringResource
- func (er *ExpiringResource) GetResource(state interface{}) (interface{}, error)
- type ResponseError
Constants ¶
const ( ContentTypeAppJSON = "application/json" ContentTypeAppXML = "application/xml" )
const ( HeaderAuthorization = "Authorization" HeaderAuxiliaryAuthorization = "x-ms-authorization-auxiliary" HeaderAzureAsync = "Azure-AsyncOperation" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderLocation = "Location" HeaderOperationLocation = "Operation-Location" HeaderRetryAfter = "Retry-After" HeaderUserAgent = "User-Agent" HeaderXmsDate = "x-ms-date" )
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.20.0" )
const BearerTokenPrefix = "Bearer "
const (
DefaultMaxRetries = 3
)
Variables ¶
ErrNoBody is returned if the response didn't contain a body.
Functions ¶
func Delay ¶
Delay waits for the duration to elapse or the context to be cancelled.
func EndpointToScope ¶
EndpointToScope converts the provided URL endpoint to its default scope.
func GetJSON ¶
GetJSON reads the response body into a raw JSON object. It returns ErrNoBody if there was no content.
func HasStatusCode ¶
HasStatusCode returns true if the Response's status code is one of the specified values.
func NewResponseError ¶
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 ¶
RetryAfter returns non-zero if the response contains a Retry-After header value.
Types ¶
type AcquireResource ¶
type AcquireResource func(state interface{}) (newResource interface{}, newExpiration time.Time, err error)
AcquireResource abstracts a method for refreshing an expiring resource.
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 ExpiringResource ¶
type ExpiringResource struct {
// contains filtered or unexported fields
}
ExpiringResource is a temporal resource (usually a credential), that requires periodic refreshing.
func NewExpiringResource ¶
func NewExpiringResource(ar AcquireResource) *ExpiringResource
NewExpiringResource creates a new ExpiringResource that uses the specified AcquireResource for refreshing.
func (*ExpiringResource) GetResource ¶
func (er *ExpiringResource) GetResource(state interface{}) (interface{}, error)
GetResource returns the underlying resource. If the resource is fresh, no refresh is performed.
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.
Source Files ¶
constants.go expiring_resource.go shared.go
- Version
- v0.20.0
- Published
- Oct 22, 2021
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 59 minutes ago –
Tools for package owners.