Skip to content

v0.0.11 - Add WithWarnEmptyRoute configuration option

Choose a tag to compare

@jackielii jackielii released this 29 Sep 11:06
· 187 commits to main since this release

What's Changed

✨ New Features

  • WithWarnEmptyRoute configuration option - Add configurable warning system for pages that have neither handler methods nor children
  • Flexible warning modes - Support custom warning functions, default stdout warnings, or completely suppressed warnings
  • Developer-friendly feedback - Help identify forgotten Page() methods or structural issues in route definitions

🐛 Bug Fixes

  • Fixed registerPageItem logic - Properly return early for empty pages to prevent nil handler registration
  • Improved error handling - Better handling of pages without handlers or children during route registration

🧪 Testing

  • Comprehensive test coverage - Added tests for all WithWarnEmptyRoute functionality modes
  • Edge case testing - Tests for custom warnings, default warnings, and suppressed warnings

📋 Usage Examples

// Use default warning (prints to stdout)
sp := structpages.New(structpages.WithWarnEmptyRoute(nil))

// Custom warning function  
sp := structpages.New(structpages.WithWarnEmptyRoute(func(pn *PageNode) {
    log.Printf("Skipping empty page: %s", pn.Name)
}))

// Suppress warnings entirely
sp := structpages.New(structpages.WithWarnEmptyRoute(func(*PageNode) {}))

🎯 Problem Solved

Previously, pages without handlers or children would cause silent issues or be skipped without notice. Now developers get clear feedback about these structural issues, helping them identify missing Page() methods (like the NptEventDeletePage example in the user's application).

Full Changelog: v0.0.10...v0.0.11