Releases: go-pkgz/routegroup
Version 1.6.0
What's Changed
UX Improvement: Auto-Group Creation in Route()
The Route() method now automatically creates a sub-group when called on the root bundle. This fixes a common UX issue where users would call router.Route(...) expecting isolated middleware scope but accidentally modify the root bundle's global middleware stack.
Before:
router := routegroup.New(http.NewServeMux())
router.Route(func(b *routegroup.Bundle) {
b.Use(middleware) // accidentally adds to root!
b.HandleFunc("/api", handler)
})After (v1.6.0):
router := routegroup.New(http.NewServeMux())
router.Route(func(b *routegroup.Bundle) {
b.Use(middleware) // now properly isolated to sub-group
b.HandleFunc("/api", handler)
})Breaking Change Note
This is technically a behavior change that may affect code relying on the old pattern of router.Route() modifying the root bundle directly. However, this old behavior was rarely the intended use case and often led to bugs.
The following patterns are now equivalent:
router.Route(fn)router.Group().Route(fn)
Existing code using router.Mount("/path").Route(fn) or router.Group().Route(fn) is unaffected.
Internal Fix
Fixed root bundle locking to properly maintain the Use-before-routes contract when routes are registered via Route() auto-wrapping.
Full Changelog: v1.5.3...v1.6.0
Version 1.5.3
What's Changed
Bug Fixes
Details
- Custom NotFound handlers no longer incorrectly override 405 (Method Not Allowed) responses
- Requests to valid paths with incorrect HTTP methods now properly return 405 with Allow header
- NotFoundHandler documentation updated to reflect actual behavior
Implementation
- Lightweight status probing mechanism to distinguish between true 404s and method mismatches
- No reflection used, clean and maintainable solution
- Comprehensive test coverage added
Full Changelog: v1.5.2...v1.5.3
Version 1.5.2
Bug Fixes
- Fix double middleware execution on root group (#24)
- Fix empty Request.Pattern in global middlewares (#24)
Improvements
- Global middlewares now have access to route patterns for better observability
- Added comprehensive middleware test suite
- Improved test coverage to 98.1%
Breaking Changes
- Requires Go 1.23 or higher (previously Go 1.22)
- Needed for proper Request.Pattern support
Technical Details
This release fixes a critical bug introduced in v1.5.0 where middlewares were executed twice when using the root bundle. The issue has been resolved by restructuring how middlewares are applied - global middlewares now execute only at serve time with proper pattern visibility.
Thanks to @kerbrek for reporting the issue!
Version 1.5.1
Bug Fix
- Fixed path parameter extraction regression introduced in v1.5.0 (#22, #23)
- Path parameters now work correctly with mounted groups
- Added comprehensive test coverage for Go 1.22+ path parameter features
Testing Improvements
- Refactored test suite for better maintainability
- Split large 3367-line test file into 6 focused test files
- Fixed fragile test method selection issues
What's Changed
- Fix path parameter extraction in ServeHTTP by @umputun in #23
- Test refactoring: split large test file into focused test files
Full Changelog: v1.5.0...v1.5.1
v1.5.0
What's Changed
Bug Fixes
- Fix HTTP 405 Method Not Allowed responses (#21)
- Routes now correctly return 405 Method Not Allowed (with Allow header) instead of 404 when wrong HTTP method is used on existing paths
- Preserves standard library's HTTP method matching behavior
Architecture Improvements
- Redesigned middleware application to apply global middlewares at serve time rather than route registration time
- Added middleware ordering enforcement - calling
Use()after registering routes on the same bundle will now panic with a descriptive error - Improved bundle hierarchy tracking to prevent middleware double-application
Documentation
- Clarified 404/405 behavior in README
- Added note about non-concurrent route registration
- Updated examples to demonstrate proper middleware ordering patterns
Maintenance
- Fixed improper defer usage in test loops
DisableNotFoundHandler()is now a no-op (preserved for backward compatibility)
Compatibility
This release maintains full backward compatibility. The only breaking change is intentional - calling Use() after routes are registered will panic to prevent subtle middleware ordering bugs.
Full Changelog: v1.4.1...v1.5.0
Version 1.4.0
What's Changed
Full Changelog: v1.3.1...v1.4.0
Version 1.3.0
What's Changed
Full Changelog: v1.2.0...v1.3.0
Version 1.2.0
What's Changed
- Add the ability to set a custom not-found handler. by @umputun in #10
- Refactor root path registration logic by @umputun in #11
Full Changelog: v1.1.1...v1.2.0
Version 1.1.1
- refactor check for registered root route
- simplify registration code
Full Changelog: v1.1.0...v1.1.1
Version 1.1.0
What's Changed
- Fix README.md examples by @meandnano in #4
- [master] fix allocate middlewares slice by @FedorovVladimir in #5
- simplify test confusions with mux usage; remove Mux accessor by @umputun in #6
- Add a catch-all route if one not registered yet by @umputun in #8
New Contributors
- @meandnano made their first contribution in #4
- @FedorovVladimir made their first contribution in #5
Full Changelog: v1.0.0...v1.1.0