1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-26 00:11:46 +02:00
Commit Graph

4 Commits

Author SHA1 Message Date
Vishal Rana
9c11b31cc9 Document ContextTimeout middleware with comprehensive examples
Addresses issue #2745 by providing complete documentation for the ContextTimeout
middleware, which was previously undocumented despite being the recommended
approach over the deprecated Timeout middleware.

**Documentation Added:**

**Overview & Key Differences:**
- Clear explanation of why ContextTimeout is preferred over Timeout middleware
- Highlights safety improvements (no response writer interference, no data races)
- Explains cooperative cancellation model

**Configuration Examples:**
- Basic usage with simple timeout
- Custom error handling for timeout responses
- Route-specific skipping with Skipper
- Advanced configuration patterns

**Handler Examples (3 detailed scenarios):**
- Context-aware database queries with proper error handling
- Long-running operations using goroutines and select statements
- HTTP client requests with context propagation

**Best Practices & Common Patterns:**
- Database operations: `db.QueryContext(ctx, ...)`
- HTTP requests: `http.NewRequestWithContext(ctx, ...)`
- Redis operations: `client.Get(ctx, key)`
- CPU-intensive loops with context checking

**Enhanced Field Documentation:**
- Detailed explanations for Skipper, ErrorHandler, and Timeout fields
- Examples for each configuration option
- Recommended timeout values for different use cases

**Function Documentation:**
- Comprehensive ContextTimeout() documentation with usage examples
- Enhanced ContextTimeoutWithConfig() with advanced patterns
- ToMiddleware() method documentation for validation scenarios

This resolves user confusion about which timeout middleware to use and
provides practical examples showing how handlers should be implemented
to work effectively with context-based timeouts.

Fixes #2745

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-15 19:55:49 -07:00
Martti T
a842444e8f Add SPDX licence comments to files. See https://spdx.dev/learn/handling-license-info/ (#2604) 2024-03-09 11:21:24 +02:00
eiei114
3950c444b7 fix some typos (#2511) 2023-09-13 22:41:58 +03:00
Hakan Kutluay
82a964c657 Add context timeout middleware (#2380)
Add context timeout middleware


Co-authored-by: Erhan Akpınar <erhan.akpinar@yemeksepeti.com>
Co-authored-by: @erhanakp
2023-02-01 22:38:20 +02:00