Documentation
¶
Overview ¶
Package middleware provides HTTP middleware components for the anytype client
Package middleware provides HTTP middleware components for the anytype client
Index ¶
- func WithCustomRetry(config RetryConfig) func(HTTPDoer) HTTPDoer
- func WithRetry() func(HTTPDoer) HTTPDoer
- func WithValidator(ctx context.Context, validator Validator) context.Context
- type Chain
- type DisconnectConfig
- type DisconnectMiddleware
- type HTTPDoer
- type RetryConfig
- type RetryMiddleware
- type ValidationMiddleware
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCustomRetry ¶
func WithCustomRetry(config RetryConfig) func(HTTPDoer) HTTPDoer
WithCustomRetry returns a middleware function that applies retry logic with custom configuration
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents a middleware chain
type DisconnectConfig ¶
type DisconnectConfig struct {
// ReconnectDelay is the delay before attempting to reconnect
ReconnectDelay time.Duration
// MaxReconnectAttempts is the maximum number of reconnect attempts
MaxReconnectAttempts int
// OnDisconnect is called when a disconnection is detected
OnDisconnect func()
// OnReconnect is called when a connection is re-established
OnReconnect func()
}
DisconnectConfig configures the disconnect handling middleware
func DefaultDisconnectConfig ¶
func DefaultDisconnectConfig() DisconnectConfig
DefaultDisconnectConfig provides sensible defaults for disconnect configuration
type DisconnectMiddleware ¶
type DisconnectMiddleware struct {
Next HTTPDoer
Config DisconnectConfig
// contains filtered or unexported fields
}
DisconnectMiddleware handles temporary network disconnections
func NewDisconnectMiddleware ¶
func NewDisconnectMiddleware(next HTTPDoer, config DisconnectConfig) *DisconnectMiddleware
NewDisconnectMiddleware creates a new disconnect handling middleware
func (*DisconnectMiddleware) IsConnected ¶
func (m *DisconnectMiddleware) IsConnected() bool
IsConnected returns the current connection status
type RetryConfig ¶
type RetryConfig struct {
// MaxRetries is the maximum number of retries
MaxRetries int
// RetryDelay is the base delay between retries
RetryDelay time.Duration
// MaxRetryDelay is the maximum delay between retries
MaxRetryDelay time.Duration
// RetryableStatusCodes defines HTTP status codes that should trigger a retry
RetryableStatusCodes []int
// ShouldRetry is a custom function to determine if a request should be retried
ShouldRetry func(*http.Response, error) bool
}
RetryConfig configures the retry middleware
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig provides sensible defaults for retry configuration
type RetryMiddleware ¶
type RetryMiddleware struct {
Next HTTPDoer
Config RetryConfig
}
RetryMiddleware implements a retry strategy for HTTP requests
func NewRetryMiddleware ¶
func NewRetryMiddleware(next HTTPDoer, config RetryConfig) *RetryMiddleware
NewRetryMiddleware creates a new retry middleware with the given configuration
type ValidationMiddleware ¶
type ValidationMiddleware struct {
Next HTTPDoer
}
ValidationMiddleware validates requests before they are sent
func NewValidationMiddleware ¶
func NewValidationMiddleware(next HTTPDoer) *ValidationMiddleware
NewValidationMiddleware creates a new validation middleware