nethttplibrary

package module
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 23 Imported by: 20

README

Kiota Http Library for Go

Go

The Kiota HTTP Library for Go is the Go HTTP library implementation with net/http.

A Kiota generated project will need a reference to a HTTP package to make HTTP requests to an API endpoint.

Read more about Kiota here.

Using the Kiota Http Library for Go

go get github.com/microsoft/kiota-http-go
httpAdapter, err := kiotahttp.NewNetHttpRequestAdapter(authProvider)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Documentation

Overview

Package nethttplibrary implements the Kiota abstractions with net/http to execute the requests. It also provides a middleware infrastructure with some default middleware handlers like the retry handler and the redirect handler.

Index

Constants

View Source
const AuthenticateChallengedEventKey = "com.microsoft.kiota.authenticate_challenge_received"
View Source
const ChaosHandlerTriggeredEventKey = "com.microsoft.kiota.chaos_handler_triggered"

ChaosHandlerTriggeredEventKey is the key used for the open telemetry event

View Source
const ErrorBodyFoundAttributeName = "com.microsoft.kiota.error.body_found"

ErrorBodyFoundAttributeName is the attribute name used to indicate whether the error response contained a body

View Source
const ErrorMappingFoundAttributeName = "com.microsoft.kiota.error.mapping_found"

ErrorMappingFoundAttributeName is the attribute name used to indicate whether an error code mapping was found.

View Source
const EventResponseHandlerInvokedKey = "com.microsoft.kiota.response_handler_invoked"

Variables

This section is empty.

Functions

func GetClientWithAuthenticatedProxySettings added in v0.8.0

func GetClientWithAuthenticatedProxySettings(proxyUrlStr string, username string, password string, middleware ...Middleware) (*nethttp.Client, error)

GetClientWithAuthenticatedProxySettings creates a new default net/http client with a proxy url and default middleware Not providing any middleware would result in having default middleware provided

func GetClientWithProxySettings added in v0.8.0

func GetClientWithProxySettings(proxyUrlStr string, middleware ...Middleware) (*nethttp.Client, error)

GetClientWithProxySettings creates a new default net/http client with a proxy url and default middleware Not providing any middleware would result in having default middleware provided

func GetDefaultClient

func GetDefaultClient(middleware ...Middleware) *nethttp.Client

GetDefaultClient creates a new default net/http client with the options configured for the Kiota request adapter

func GetDefaultTransport

func GetDefaultTransport() nethttp.RoundTripper

GetDefaultTransport returns the default http transport used by the library

func NewCustomTransport

func NewCustomTransport(middlewares ...Middleware) *customTransport

NewCustomTransport creates a new custom transport for http client with the provided set of middleware

func NewCustomTransportWithParentTransport

func NewCustomTransportWithParentTransport(parentTransport nethttp.RoundTripper, middlewares ...Middleware) *customTransport

NewCustomTransportWithParentTransport creates a new custom transport which relies on the provided transport for http client with the provided set of middleware

func NopCloser added in v0.11.0

func NopCloser(r io.ReadSeeker) io.ReadSeekCloser

func ReplacePathTokens added in v0.16.2

func ReplacePathTokens(path string, replacementPairs map[string]string) string

ReplacePathTokens invokes token replacement logic on the given url path

Types

type ChaosHandler added in v0.6.0

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

func NewChaosHandler added in v0.6.0

func NewChaosHandler() *ChaosHandler

NewChaosHandler creates a new ChaosHandler with default configuration options of Random errors at 10%

func NewChaosHandlerWithOptions added in v0.6.0

func NewChaosHandlerWithOptions(handlerOptions *ChaosHandlerOptions) (*ChaosHandler, error)

NewChaosHandlerWithOptions creates a new ChaosHandler with the configured options

func (ChaosHandler) Intercept added in v0.6.0

func (middleware ChaosHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

type ChaosHandlerOptions added in v0.6.0

type ChaosHandlerOptions struct {
	BaseUrl         string
	ChaosStrategy   ChaosStrategy
	StatusCode      int
	StatusMessage   string
	ChaosPercentage int
	ResponseBody    *nethttp.Response
	Headers         map[string][]string
	StatusMap       map[string]map[string]int
}

ChaosHandlerOptions is a configuration struct holding behavior defined options for a chaos handler

BaseUrl represent the host url for in ChaosStrategy Specifies the strategy used for the Testing Handler -> RANDOM/MANUAL StatusCode Status code to be returned as part of the error response StatusMessage Message to be returned as part of the error response ChaosPercentage The percentage of randomness/chaos in the handler ResponseBody The response body to be returned as part of the error response Headers The response headers to be returned as part of the error response StatusMap The Map passed by user containing url-statusCode info

func (*ChaosHandlerOptions) GetBaseUrl added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetBaseUrl() string

func (*ChaosHandlerOptions) GetChaosPercentage added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetChaosPercentage() int

func (*ChaosHandlerOptions) GetChaosStrategy added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetChaosStrategy() ChaosStrategy

func (*ChaosHandlerOptions) GetHeaders added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetHeaders() map[string][]string

func (*ChaosHandlerOptions) GetKey added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetKey() abstractions.RequestOptionKey

GetKey returns ChaosHandlerOptions unique name in context object

func (*ChaosHandlerOptions) GetResponseBody added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetResponseBody() *nethttp.Response

func (*ChaosHandlerOptions) GetStatusCode added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetStatusCode() int

func (*ChaosHandlerOptions) GetStatusMap added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetStatusMap() map[string]map[string]int

func (*ChaosHandlerOptions) GetStatusMessage added in v0.6.0

func (handlerOptions *ChaosHandlerOptions) GetStatusMessage() string

type ChaosStrategy added in v0.6.0

type ChaosStrategy int
const (
	Manual ChaosStrategy = iota
	Random
)

type CompressionHandler

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

CompressionHandler represents a compression middleware

func NewCompressionHandler

func NewCompressionHandler() *CompressionHandler

NewCompressionHandler creates an instance of a compression middleware

func NewCompressionHandlerWithOptions

func NewCompressionHandlerWithOptions(option CompressionOptions) *CompressionHandler

NewCompressionHandlerWithOptions creates an instance of the compression middlerware with specified configurations.

func (*CompressionHandler) Intercept

func (c *CompressionHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *http.Request) (*http.Response, error)

Intercept is invoked by the middleware pipeline to either move the request/response to the next middleware in the pipeline

type CompressionOptions

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

CompressionOptions is a configuration object for the CompressionHandler middleware

func NewCompressionOptions

func NewCompressionOptions(enableCompression bool) CompressionOptions

NewCompressionOptions creates a configuration object for the CompressionHandler

func (CompressionOptions) GetKey

GetKey returns CompressionOptions unique name in context object

func (CompressionOptions) ShouldCompress

func (o CompressionOptions) ShouldCompress() bool

ShouldCompress reads compression setting form CompressionOptions

type HeadersInspectionHandler added in v1.1.0

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

HeadersInspectionHandler allows inspecting of the headers of the request and response via a request option

func NewHeadersInspectionHandler added in v1.1.0

func NewHeadersInspectionHandler() *HeadersInspectionHandler

NewHeadersInspectionHandler creates a new HeadersInspectionHandler with default options

func NewHeadersInspectionHandlerWithOptions added in v1.1.0

func NewHeadersInspectionHandlerWithOptions(options HeadersInspectionOptions) *HeadersInspectionHandler

NewHeadersInspectionHandlerWithOptions creates a new HeadersInspectionHandler with the given options

func (HeadersInspectionHandler) Intercept added in v1.1.0

func (middleware HeadersInspectionHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

Intercept implements the interface and evaluates whether to retry a failed request.

type HeadersInspectionOptions added in v1.1.0

type HeadersInspectionOptions struct {
	InspectRequestHeaders  bool
	InspectResponseHeaders bool
	RequestHeaders         *abstractions.RequestHeaders
	ResponseHeaders        *abstractions.ResponseHeaders
}

HeadersInspectionHandlerOptions is the options to use when inspecting headers

func NewHeadersInspectionOptions added in v1.1.0

func NewHeadersInspectionOptions() *HeadersInspectionOptions

NewHeadersInspectionOptions creates a new HeadersInspectionOptions with default options

func (*HeadersInspectionOptions) GetInspectRequestHeaders added in v1.1.0

func (o *HeadersInspectionOptions) GetInspectRequestHeaders() bool

GetInspectRequestHeaders returns true if the request headers should be inspected

func (*HeadersInspectionOptions) GetInspectResponseHeaders added in v1.1.0

func (o *HeadersInspectionOptions) GetInspectResponseHeaders() bool

GetInspectResponseHeaders returns true if the response headers should be inspected

func (*HeadersInspectionOptions) GetKey added in v1.1.0

GetKey returns the key for the HeadersInspectionOptions

func (*HeadersInspectionOptions) GetRequestHeaders added in v1.1.0

func (o *HeadersInspectionOptions) GetRequestHeaders() *abstractions.RequestHeaders

GetRequestHeaders returns the request headers

func (*HeadersInspectionOptions) GetResponseHeaders added in v1.1.0

func (o *HeadersInspectionOptions) GetResponseHeaders() *abstractions.ResponseHeaders

GetResponseHeaders returns the response headers

type Middleware

type Middleware interface {
	// Intercept intercepts the request and returns the response. The implementer MUST call pipeline.Next()
	Intercept(Pipeline, int, *nethttp.Request) (*nethttp.Response, error)
}

Middleware interface for cross cutting concerns with HTTP requests and responses.

func GetDefaultMiddlewares

func GetDefaultMiddlewares() []Middleware

GetDefaultMiddlewares creates a new default set of middlewares for the Kiota request adapter

func GetDefaultMiddlewaresWithOptions added in v1.3.0

func GetDefaultMiddlewaresWithOptions(requestOptions ...abs.RequestOption) ([]Middleware, error)

GetDefaultMiddlewaresWithOptions creates a new default set of middlewares for the Kiota request adapter with options

type NetHttpRequestAdapter

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

NetHttpRequestAdapter implements the RequestAdapter interface using net/http

func NewNetHttpRequestAdapter

func NewNetHttpRequestAdapter(authenticationProvider absauth.AuthenticationProvider) (*NetHttpRequestAdapter, error)

NewNetHttpRequestAdapter creates a new NetHttpRequestAdapter with the given parameters

func NewNetHttpRequestAdapterWithParseNodeFactory

func NewNetHttpRequestAdapterWithParseNodeFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory) (*NetHttpRequestAdapter, error)

NewNetHttpRequestAdapterWithParseNodeFactory creates a new NetHttpRequestAdapter with the given parameters

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory) (*NetHttpRequestAdapter, error)

NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactory creates a new NetHttpRequestAdapter with the given parameters

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory, httpClient *nethttp.Client) (*NetHttpRequestAdapter, error)

NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClient creates a new NetHttpRequestAdapter with the given parameters

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClientAndObservabilityOptions added in v0.9.0

func NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClientAndObservabilityOptions(authenticationProvider absauth.AuthenticationProvider, parseNodeFactory absser.ParseNodeFactory, serializationWriterFactory absser.SerializationWriterFactory, httpClient *nethttp.Client, observabilityOptions ObservabilityOptions) (*NetHttpRequestAdapter, error)

NewNetHttpRequestAdapterWithParseNodeFactoryAndSerializationWriterFactoryAndHttpClientAndObservabilityOptions creates a new NetHttpRequestAdapter with the given parameters

func (*NetHttpRequestAdapter) ConvertToNativeRequest added in v0.13.0

func (a *NetHttpRequestAdapter) ConvertToNativeRequest(context context.Context, requestInfo *abs.RequestInformation) (any, error)

ConvertToNativeRequest converts the given RequestInformation into a native HTTP request.

func (*NetHttpRequestAdapter) EnableBackingStore

func (a *NetHttpRequestAdapter) EnableBackingStore(factory store.BackingStoreFactory)

EnableBackingStore enables the backing store proxies for the SerializationWriters and ParseNodes in use.

func (*NetHttpRequestAdapter) GetBaseUrl

func (a *NetHttpRequestAdapter) GetBaseUrl() string

GetBaseUrl gets the base url for every request.

func (*NetHttpRequestAdapter) GetSerializationWriterFactory

func (a *NetHttpRequestAdapter) GetSerializationWriterFactory() absser.SerializationWriterFactory

GetSerializationWriterFactory returns the serialization writer factory currently in use for the request adapter service.

func (*NetHttpRequestAdapter) Send added in v0.13.0

func (a *NetHttpRequestAdapter) Send(ctx context.Context, requestInfo *abs.RequestInformation, constructor absser.ParsableFactory, errorMappings abs.ErrorMappings) (absser.Parsable, error)

Send executes the HTTP request specified by the given RequestInformation and returns the deserialized response model.

func (*NetHttpRequestAdapter) SendCollection added in v0.13.0

func (a *NetHttpRequestAdapter) SendCollection(ctx context.Context, requestInfo *abs.RequestInformation, constructor absser.ParsableFactory, errorMappings abs.ErrorMappings) ([]absser.Parsable, error)

SendCollection executes the HTTP request specified by the given RequestInformation and returns the deserialized response model collection.

func (*NetHttpRequestAdapter) SendEnum added in v0.13.0

func (a *NetHttpRequestAdapter) SendEnum(ctx context.Context, requestInfo *abs.RequestInformation, parser absser.EnumFactory, errorMappings abs.ErrorMappings) (any, error)

SendEnum executes the HTTP request specified by the given RequestInformation and returns the deserialized response model.

func (*NetHttpRequestAdapter) SendEnumCollection added in v0.13.0

func (a *NetHttpRequestAdapter) SendEnumCollection(ctx context.Context, requestInfo *abs.RequestInformation, parser absser.EnumFactory, errorMappings abs.ErrorMappings) ([]any, error)

SendEnumCollection executes the HTTP request specified by the given RequestInformation and returns the deserialized response model collection.

func (*NetHttpRequestAdapter) SendNoContent added in v0.13.0

func (a *NetHttpRequestAdapter) SendNoContent(ctx context.Context, requestInfo *abs.RequestInformation, errorMappings abs.ErrorMappings) error

SendNoContent executes the HTTP request specified by the given RequestInformation with no return content.

func (*NetHttpRequestAdapter) SendPrimitive added in v0.13.0

func (a *NetHttpRequestAdapter) SendPrimitive(ctx context.Context, requestInfo *abs.RequestInformation, typeName string, errorMappings abs.ErrorMappings) (any, error)

SendPrimitive executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model.

func (*NetHttpRequestAdapter) SendPrimitiveCollection added in v0.13.0

func (a *NetHttpRequestAdapter) SendPrimitiveCollection(ctx context.Context, requestInfo *abs.RequestInformation, typeName string, errorMappings abs.ErrorMappings) ([]any, error)

SendPrimitiveCollection executes the HTTP request specified by the given RequestInformation and returns the deserialized primitive response model collection.

func (*NetHttpRequestAdapter) SetBaseUrl

func (a *NetHttpRequestAdapter) SetBaseUrl(baseUrl string)

SetBaseUrl sets the base url for every request.

type ObservabilityOptions added in v0.9.0

type ObservabilityOptions struct {
	// Whether to include attributes which could contains EUII information like URLs
	IncludeEUIIAttributes bool
}

ObservabilityOptions holds the tracing, metrics and logging configuration for the request adapter

func (*ObservabilityOptions) GetIncludeEUIIAttributes added in v0.9.0

func (o *ObservabilityOptions) GetIncludeEUIIAttributes() bool

GetIncludeEUIIAttributes returns whether to include attributes which could contains EUII information

func (*ObservabilityOptions) GetKey added in v0.9.0

func (*ObservabilityOptions) GetTracerInstrumentationName added in v0.9.0

func (o *ObservabilityOptions) GetTracerInstrumentationName() string

GetTracerInstrumentationName returns the observability name to use for the tracer

func (*ObservabilityOptions) SetIncludeEUIIAttributes added in v0.9.0

func (o *ObservabilityOptions) SetIncludeEUIIAttributes(value bool)

SetIncludeEUIIAttributes set whether to include attributes which could contains EUII information

type ObservabilityOptionsInt added in v0.9.0

type ObservabilityOptionsInt interface {
	abs.RequestOption
	GetTracerInstrumentationName() string
	GetIncludeEUIIAttributes() bool
	SetIncludeEUIIAttributes(value bool)
}

ObservabilityOptionsInt defines the options contract for handlers

func GetObservabilityOptionsFromRequest added in v0.9.0

func GetObservabilityOptionsFromRequest(req *nethttp.Request) ObservabilityOptionsInt

GetObservabilityOptionsFromRequest returns the observability options from the request context

type ParametersNameDecodingHandler added in v0.2.0

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

ParametersNameDecodingHandler decodes special characters in the request query parameters that had to be encoded due to RFC 6570 restrictions names before executing the request.

func NewParametersNameDecodingHandler added in v0.2.0

func NewParametersNameDecodingHandler() *ParametersNameDecodingHandler

NewParametersNameDecodingHandler creates a new ParametersNameDecodingHandler with default options

func NewParametersNameDecodingHandlerWithOptions added in v0.2.0

func NewParametersNameDecodingHandlerWithOptions(options ParametersNameDecodingOptions) *ParametersNameDecodingHandler

NewParametersNameDecodingHandlerWithOptions creates a new ParametersNameDecodingHandler with the given options

func (*ParametersNameDecodingHandler) Intercept added in v0.2.0

func (handler *ParametersNameDecodingHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

Intercept implements the RequestInterceptor interface and decodes the parameters name

type ParametersNameDecodingOptions added in v0.2.0

type ParametersNameDecodingOptions struct {
	// Enable defines if the parameters name decoding should be enabled
	Enable bool
	// ParametersToDecode defines the characters that should be decoded
	ParametersToDecode []byte
}

ParametersNameDecodingOptions defines the options for the ParametersNameDecodingHandler

func (*ParametersNameDecodingOptions) GetEnable added in v0.2.0

func (options *ParametersNameDecodingOptions) GetEnable() bool

GetEnable returns the enable value from the option

func (*ParametersNameDecodingOptions) GetKey added in v0.2.0

GetKey returns the key value to be used when the option is added to the request context

func (*ParametersNameDecodingOptions) GetParametersToDecode added in v0.2.0

func (options *ParametersNameDecodingOptions) GetParametersToDecode() []byte

GetParametersToDecode returns the parametersToDecode value from the option

type Pipeline

type Pipeline interface {
	// Next moves the request object through middlewares in the pipeline
	Next(req *nethttp.Request, middlewareIndex int) (*nethttp.Response, error)
}

Pipeline contract for middleware infrastructure

type RedirectHandler

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

RedirectHandler handles redirect responses and follows them according to the options specified.

func NewRedirectHandler

func NewRedirectHandler() *RedirectHandler

NewRedirectHandler creates a new redirect handler with the default options.

func NewRedirectHandlerWithOptions

func NewRedirectHandlerWithOptions(options RedirectHandlerOptions) *RedirectHandler

NewRedirectHandlerWithOptions creates a new redirect handler with the specified options.

func (RedirectHandler) Intercept

func (middleware RedirectHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

Intercept implements the interface and evaluates whether to follow a redirect response.

type RedirectHandlerOptions

type RedirectHandlerOptions struct {
	// A callback that determines whether to redirect or not.
	ShouldRedirect func(req *nethttp.Request, res *nethttp.Response) bool
	// The maximum number of redirects to follow.
	MaxRedirects int
}

RedirectHandlerOptions to use when evaluating whether to redirect or not.

func (*RedirectHandlerOptions) GetKey

func (options *RedirectHandlerOptions) GetKey() abs.RequestOptionKey

GetKey returns the key value to be used when the option is added to the request context

func (*RedirectHandlerOptions) GetMaxRedirect

func (options *RedirectHandlerOptions) GetMaxRedirect() int

GetMaxRedirect returns the maximum number of redirects to follow.

func (*RedirectHandlerOptions) GetShouldRedirect

func (options *RedirectHandlerOptions) GetShouldRedirect() func(req *nethttp.Request, res *nethttp.Response) bool

GetShouldRedirect returns the redirection evaluation function.

type RetryHandler

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

RetryHandler handles transient HTTP responses and retries the request given the retry options

func NewRetryHandler

func NewRetryHandler() *RetryHandler

NewRetryHandler creates a new RetryHandler with default options

func NewRetryHandlerWithOptions

func NewRetryHandlerWithOptions(options RetryHandlerOptions) *RetryHandler

NewRetryHandlerWithOptions creates a new RetryHandler with the given options

func (RetryHandler) Intercept

func (middleware RetryHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

Intercept implements the interface and evaluates whether to retry a failed request.

type RetryHandlerOptions

type RetryHandlerOptions struct {
	// Callback to determine if the request should be retried
	ShouldRetry func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool
	// The maximum number of times a request can be retried
	MaxRetries int
	// The delay in seconds between retries
	DelaySeconds int
}

RetryHandlerOptions to apply when evaluating the response for retrial

func (*RetryHandlerOptions) GetDelaySeconds

func (options *RetryHandlerOptions) GetDelaySeconds() int

GetDelaySeconds returns the delays in seconds between retries

func (*RetryHandlerOptions) GetKey

func (options *RetryHandlerOptions) GetKey() abs.RequestOptionKey

GetKey returns the key value to be used when the option is added to the request context

func (*RetryHandlerOptions) GetMaxRetries

func (options *RetryHandlerOptions) GetMaxRetries() int

GetMaxRetries returns the maximum number of times a request can be retried

func (*RetryHandlerOptions) GetShouldRetry

func (options *RetryHandlerOptions) GetShouldRetry() func(delay time.Duration, executionCount int, request *nethttp.Request, response *nethttp.Response) bool

GetShouldRetry returns the should retry callback function which evaluates the response for retrial

type UrlReplaceHandler added in v0.15.0

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

UrlReplaceHandler is a middleware handler that replaces url segments in the uri path.

func NewUrlReplaceHandler added in v0.15.0

func NewUrlReplaceHandler(enabled bool, replacementPairs map[string]string) *UrlReplaceHandler

NewUrlReplaceHandler creates a configuration object for the CompressionHandler

func (*UrlReplaceHandler) Intercept added in v0.15.0

func (c *UrlReplaceHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *http.Request) (*http.Response, error)

Intercept is invoked by the middleware pipeline to either move the request/response to the next middleware in the pipeline

type UrlReplaceOptions added in v0.15.0

type UrlReplaceOptions struct {
	Enabled          bool
	ReplacementPairs map[string]string
}

UrlReplaceOptions is a configuration object for the UrlReplaceHandler middleware

func (*UrlReplaceOptions) GetKey added in v0.15.0

GetKey returns UrlReplaceOptions unique name in context object

func (*UrlReplaceOptions) GetReplacementPairs added in v0.15.0

func (u *UrlReplaceOptions) GetReplacementPairs() map[string]string

GetReplacementPairs reads ReplacementPairs settings from UrlReplaceOptions

func (*UrlReplaceOptions) IsEnabled added in v0.15.0

func (u *UrlReplaceOptions) IsEnabled() bool

IsEnabled reads Enabled setting from UrlReplaceOptions

type UserAgentHandler added in v0.12.0

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

UserAgentHandler adds the product to the user agent header.

func NewUserAgentHandler added in v0.12.0

func NewUserAgentHandler() *UserAgentHandler

NewUserAgentHandler creates a new user agent handler with the default options.

func NewUserAgentHandlerWithOptions added in v0.12.0

func NewUserAgentHandlerWithOptions(options *UserAgentHandlerOptions) *UserAgentHandler

NewUserAgentHandlerWithOptions creates a new user agent handler with the specified options.

func (UserAgentHandler) Intercept added in v0.12.0

func (middleware UserAgentHandler) Intercept(pipeline Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

type UserAgentHandlerOptions added in v0.12.0

type UserAgentHandlerOptions struct {
	Enabled        bool
	ProductName    string
	ProductVersion string
}

UserAgentHandlerOptions to use when adding the product to the user agent header.

func NewUserAgentHandlerOptions added in v0.12.0

func NewUserAgentHandlerOptions() *UserAgentHandlerOptions

NewUserAgentHandlerOptions creates a new user agent handler options with the default values.

func (*UserAgentHandlerOptions) GetEnabled added in v0.12.0

func (options *UserAgentHandlerOptions) GetEnabled() bool

GetEnabled returns the value of the enabled property

func (*UserAgentHandlerOptions) GetKey added in v0.12.0

func (options *UserAgentHandlerOptions) GetKey() abs.RequestOptionKey

GetKey returns the key value to be used when the option is added to the request context

func (*UserAgentHandlerOptions) GetProductName added in v0.12.0

func (options *UserAgentHandlerOptions) GetProductName() string

GetProductName returns the value of the product name property

func (*UserAgentHandlerOptions) GetProductVersion added in v0.12.0

func (options *UserAgentHandlerOptions) GetProductVersion() string

GetProductVersion returns the value of the product version property

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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