http

package
v3.0.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxRedirects    = 10
	ErrMaxRedirects = "stopped after maximum allowed redirects"
)

Variables

This section is empty.

Functions

func CheckRedirect

func CheckRedirect(req *http.Request, via []*http.Request) error

CheckRedirect checks the redirect policy for the HTTP client.

func DecodeBody

func DecodeBody(resp *http.Response, result any) error

DecodeBody unmarshalls the JSON response body if the result is non nil

func DecodeError

func DecodeError(resp *http.Response) error

func DecodeJobID

func DecodeJobID(resp *http.Response) string

DecodeJobID returns the jobGUID if specified in the Location response header

func DecodeJobIDAndBody

func DecodeJobIDAndBody(resp *http.Response, result any) (string, error)

DecodeJobIDAndBody returns the jobGUID if specified in the Location response header and unmarshalls the JSON response body to result if available

func DecodeJobIDOrBody

func DecodeJobIDOrBody(resp *http.Response, result any) (string, error)

DecodeJobIDOrBody returns the jobGUID if specified in the Location response header or unmarshalls the JSON response body if no job ID and result is non nil

func EncodeBody

func EncodeBody(obj any) (io.Reader, error)

func IgnoreRedirect

func IgnoreRedirect(req *http.Request) *http.Request

IgnoreRedirect sets a flag in the request's context to indicate that redirects should be ignored.

func IsIgnoredRedirect

func IsIgnoredRedirect(req *http.Request) bool

IsIgnoredRedirect checks if the 'ignore redirect' flag is set in the request's context.

func IsResponseRedirect

func IsResponseRedirect(statusCode int) bool

func IsStatusIn

func IsStatusIn(statusCode int, statuses ...int) bool

func IsStatusSuccess

func IsStatusSuccess(statusCode int) bool

func NewAuthenticatedClient

func NewAuthenticatedClient(ctx context.Context, baseClient *http.Client, tokenSourceCreator OAuthTokenSourceCreator) (*http.Client, error)

NewAuthenticatedClient creates a new http.Client with a retryableAuthTransport that supports re-authentication and request retry should a request cause a 401.

Types

type OAuthTokenSourceCreator

type OAuthTokenSourceCreator interface {
	// CreateOAuth2TokenSource creates a new OAuth2 TokenSource when called
	CreateOAuth2TokenSource(ctx context.Context) (oauth2.TokenSource, error)
}

OAuthTokenSourceCreator implementations create OAuth2 TokenSources

Jump to

Keyboard shortcuts

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