Documentation
¶
Overview ¶
Package examples demonstrates context usage patterns with the requests library.
This file shows how to use context.Context for: - Request timeout control - Request cancellation - Deadline management
Package examples demonstrates Session configuration patterns with the requests library.
This file shows how to configure Session with: - Retry policies - Middleware - Method chaining - Various configuration options
Index ¶
- func AuthenticationExample()
- func BasicSessionExample()
- func CancellationExample()
- func ClearSessionExample()
- func CloneSessionExample()
- func ContextValueExample()
- func ContextWithSessionTimeoutExample()
- func CustomRetryConditionExample()
- func DeadlineExample()
- func MethodChainingExample()
- func MiddlewareExample()
- func ParallelRequestsWithCancellationExample()
- func ProxyAndDNSExample()
- func RetryPolicyExample()
- func SessionPoolExample()
- func TimeoutExample()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticationExample ¶
func AuthenticationExample()
AuthenticationExample demonstrates various authentication methods.
func BasicSessionExample ¶
func BasicSessionExample()
BasicSessionExample demonstrates creating and configuring a basic session.
func CancellationExample ¶
func CancellationExample()
CancellationExample demonstrates canceling a request programmatically. This is useful when you need to cancel a request based on user action or other events.
func ClearSessionExample ¶
func ClearSessionExample()
ClearSessionExample demonstrates resetting a session.
func CloneSessionExample ¶
func CloneSessionExample()
CloneSessionExample demonstrates cloning a session.
func ContextValueExample ¶
func ContextValueExample()
ContextValueExample demonstrates passing values through context. Note: This is for demonstration - the requests library doesn't use context values internally.
func ContextWithSessionTimeoutExample ¶
func ContextWithSessionTimeoutExample()
ContextWithSessionTimeoutExample shows how context timeout interacts with session timeout. The shorter timeout wins.
func CustomRetryConditionExample ¶
func CustomRetryConditionExample()
CustomRetryConditionExample shows how to create custom retry conditions.
func DeadlineExample ¶
func DeadlineExample()
DeadlineExample demonstrates using context with a specific deadline. The request must complete before the deadline.
func MethodChainingExample ¶
func MethodChainingExample()
MethodChainingExample demonstrates fluent configuration.
func MiddlewareExample ¶
func MiddlewareExample()
MiddlewareExample demonstrates adding middleware to a session.
func ParallelRequestsWithCancellationExample ¶
func ParallelRequestsWithCancellationExample()
ParallelRequestsWithCancellationExample demonstrates canceling multiple parallel requests.
func ProxyAndDNSExample ¶
func ProxyAndDNSExample()
ProxyAndDNSExample demonstrates proxy and custom DNS configuration.
func RetryPolicyExample ¶
func RetryPolicyExample()
RetryPolicyExample demonstrates configuring retry behavior.
func SessionPoolExample ¶
func SessionPoolExample()
SessionPoolExample demonstrates using session pooling for high-performance scenarios.
func TimeoutExample ¶
func TimeoutExample()
TimeoutExample demonstrates using context with timeout. The request will be canceled if it takes longer than the specified timeout.
Types ¶
This section is empty.