package exported
import "github.com/Azure/azure-sdk-for-go/sdk/azcore/internal/exported"
Index ¶
- func HasStatusCode(resp *http.Response, statusCodes ...int) bool
- func NewResponseError(resp *http.Response) error
- func NopCloser(rs io.ReadSeeker) io.ReadSeekCloser
- func Payload(resp *http.Response) ([]byte, error)
- type Pipeline
- func NewPipeline(transport Transporter, policies ...Policy) Pipeline
- func (p Pipeline) Do(req *Request) (*http.Response, error)
- type Policy
- type Request
- func NewRequest(ctx context.Context, httpMethod string, endpoint string) (*Request, error)
- func (req *Request) Body() io.ReadSeekCloser
- func (req *Request) Clone(ctx context.Context) *Request
- func (req *Request) Close() error
- func (req *Request) Next() (*http.Response, error)
- func (req *Request) OperationValue(value interface{}) bool
- func (req *Request) Raw() *http.Request
- func (req *Request) RewindBody() error
- func (req *Request) SetBody(body io.ReadSeekCloser, contentType string) error
- func (req *Request) SetOperationValue(value interface{})
- type ResponseError
- type Transporter
Functions ¶
func HasStatusCode ¶
HasStatusCode returns true if the Response's status code is one of the specified values. Exported as runtime.HasStatusCode().
func NewResponseError ¶
NewResponseError creates a new *ResponseError from the provided HTTP response. Exported as runtime.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. Exported as streaming.NopCloser().
func Payload ¶
Payload reads and returns the response body or an error. On a successful read, the response body is cached. Subsequent reads will access the cached value. Exported as runtime.Payload().
Types ¶
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline represents a primitive for sending HTTP requests and receiving responses. Its behavior can be extended by specifying policies during construction. Exported as runtime.Pipeline.
func NewPipeline ¶
func NewPipeline(transport Transporter, policies ...Policy) Pipeline
NewPipeline creates a new Pipeline object from the specified Policies. Not directly exported, but used as part of runtime.NewPipeline().
func (Pipeline) Do ¶
Do is called for each and every HTTP request. It passes the request through all the Policy objects (which can transform the Request's URL/query parameters/headers) and ultimately sends the transformed HTTP request over the network.
type Policy ¶
type Policy interface { // Do applies the policy to the specified Request. When implementing a Policy, mutate the // request before calling req.Next() to move on to the next policy, and respond to the result // before returning to the caller. Do(req *Request) (*http.Response, error) }
Policy represents an extensibility point for the Pipeline that can mutate the specified Request and react to the received Response. Exported as policy.Policy.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is an abstraction over the creation of an HTTP request as it passes through the pipeline. Don't use this type directly, use NewRequest() instead. Exported as policy.Request.
func NewRequest ¶
NewRequest creates a new Request with the specified input. Exported as runtime.NewRequest().
func (*Request) Body ¶
func (req *Request) Body() io.ReadSeekCloser
Body returns the original body specified when the Request was created.
func (*Request) Clone ¶
Clone returns a deep copy of the request with its context changed to ctx.
func (*Request) Close ¶
Close closes the request body.
func (*Request) Next ¶
Next calls the next policy in the pipeline. If there are no more policies, nil and an error are returned. This method is intended to be called from pipeline policies. To send a request through a pipeline call Pipeline.Do().
func (*Request) OperationValue ¶
OperationValue looks for a value set by SetOperationValue().
func (*Request) Raw ¶
Raw returns the underlying HTTP request.
func (*Request) RewindBody ¶
RewindBody seeks the request's Body stream back to the beginning so it can be resent when retrying an operation.
func (*Request) SetBody ¶
func (req *Request) SetBody(body io.ReadSeekCloser, contentType string) error
SetBody sets the specified ReadSeekCloser as the HTTP request body.
func (*Request) SetOperationValue ¶
func (req *Request) SetOperationValue(value interface{})
SetOperationValue adds/changes a mutable key/value associated with a single operation.
type ResponseError ¶
type ResponseError struct { // ErrorCode is the error code returned by the resource provider if available. ErrorCode string // StatusCode is the HTTP status code as defined in https://pkg.go.dev/net/http#pkg-constants. StatusCode int // RawResponse is the underlying HTTP response. RawResponse *http.Response }
ResponseError is returned when a request is made to a service and the service returns a non-success HTTP status code. Use errors.As() to access this type in the error chain. Exported as azcore.ResponseError.
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
Error implements the error interface for type ResponseError. Note that the message contents are not contractual and can change over time.
type Transporter ¶
type Transporter interface { // Do sends the HTTP request and returns the HTTP response or error. Do(req *http.Request) (*http.Response, error) }
Transporter represents an HTTP pipeline transport used to send HTTP requests and receive responses. Exported as policy.Transporter.
Source Files ¶
exported.go pipeline.go request.go response_error.go
- Version
- v1.1.0
- Published
- Jun 3, 2022
- Platform
- js/wasm
- Imports
- 13 packages
- Last checked
- 46 seconds ago –
Tools for package owners.