Move strconv.Quote(config.Realm) from per-request execution
to middleware initialization for better performance.
- Pre-compute quoted realm at middleware creation time
- Avoids repeated string operations on every auth failure
- Maintains same behavior with better efficiency
Performance improvement suggested during code review.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replace manual for loop with strings.Cut for credential parsing
- Simplify realm handling to always quote according to RFC 7617
- Improve code readability and maintainability
Fixes#2794🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Modernizes the Context interface by replacing all instances of interface{}
with the more readable 'any' type alias introduced in Go 1.18.
**Changes:**
- Replaced interface{} with any in all Context interface method signatures
- Affects Get(), Set(), Bind(), Validate(), Render(), JSON(), JSONP(), XML(),
Blob(), Stream(), File(), Attachment(), Inline(), and NoContent() methods
- Total of 23 interface{} → any replacements
**Benefits:**
- Improves code readability and modernizes to Go 1.18+ standards
- No functional changes - 'any' is just an alias for interface{}
- Follows current Go best practices for new code
- Makes the API more approachable for developers familiar with modern Go
**Compatibility:**
- Zero breaking changes - 'any' and interface{} are identical
- Maintains full backward compatibility
- All existing code continues to work unchanged
This modernization aligns Echo with current Go conventions while maintaining
100% compatibility with existing applications.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <noreply@anthropic.com>
Addresses issue #2665 by providing comprehensive documentation for the Logger
middleware including:
**Configuration Examples:**
- Basic usage with default settings
- Custom simple and JSON formats
- Custom time formatting
- Header, query, form, and cookie logging
- File output configuration
- Custom tag functions
- Conditional logging with Skipper
- External logging service integration
**Detailed Tag Reference:**
- Complete list of all available tags (time, request, response, dynamic)
- Clear explanations of each tag's purpose and format
- Examples showing proper usage
**Enhanced Field Documentation:**
- Detailed descriptions for all LoggerConfig fields
- Examples for each configuration option
- Default values and behavior
**Troubleshooting Section:**
- Common issues and solutions
- Performance optimization tips
- Best practices for high-traffic applications
**Function Documentation:**
- Enhanced Logger() and LoggerWithConfig() documentation
- Example outputs and usage patterns
This makes the Logger middleware much more accessible to new users while
providing advanced configuration guidance for experienced developers.
Fixes#2665🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Adds tests for issue #2757 IP extraction edge cases where RemoteAddr
may not include a port. The enhanced extractIP function now properly
handles IPv4/IPv6 addresses without ports using net.ParseIP validation.
Test cases cover:
- IPv4 without port
- IPv6 without port
- IPv6 with port brackets
- Invalid IP format handling
Existing tests for issue #2789 response flush error handling are already
comprehensive and validate the improved error messages with ResponseWriter types.
Fixes#2757🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Revert the DefaultBinder empty body handling changes following
@aldas's concerns about:
- Body replacement potentially interfering with custom readers
- Lack of proper reproduction case for the original issue
- Potential over-engineering for an edge case
The "read one byte and reconstruct body" approach could interfere
with users who add custom readers with specific behavior.
Waiting for better reproduction case and less invasive solution.
Refs: https://github.com/labstack/echo/issues/2813#issuecomment-3294563361🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fix issue where POST requests with empty bodies and ContentLength=-1
(unknown/chunked encoding) incorrectly fail with 415 Unsupported Media Type.
The DefaultBinder.BindBody method now properly detects truly empty bodies
when ContentLength=-1 by peeking at the first byte. If no content is found,
it returns early without error. If content exists, it reconstructs the body
to preserve the original data.
Fixes#2813🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The test TestResponse_FlushPanics was expecting the old generic error
message but should now expect the improved message that includes the
specific ResponseWriter type information.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes two issues:
1. extractIP now handles RemoteAddr without port (#2757)
- Previously returned empty string for addresses like "192.168.1.1"
- Now validates with net.ParseIP and returns the IP directly
- Maintains full backwards compatibility for existing behavior
2. Response.Flush uses modern error handling (#2789)
- Replaces type assertion with http.NewResponseController
- Provides descriptive panic message with ResponseWriter type info
- Improves debugging experience when flushing is not supported
Both changes maintain full backwards compatibility while fixing edge cases.
Closes#2757Closes#2789🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Use Go 1.25 in CI
* Disable test: in Go 1.24 and earlier http.NoBody would result ContentLength=-1 but as of Go 1.25 http.NoBody would result ContentLength=0 I am too lazy to bother documenting this as 2 version specific tests.