Repository navigation
refactor: v0.8.0 — graceful shutdown, performance improvements, and bug fixes - #22
Merged
Merged
Conversation
- Fix Shutdown() not working: store http.Server in Application struct - Add RunListener() method for custom listener support - Fix Config.merge() panic on nil config: add nil check - Add MaxRequestBodySize config to prevent DoS attacks via large request bodies - Change Run() return type from void to error for better error handling
- Add sync.Pool for Context reuse to reduce GC pressure - Change EnableDebug default to false for production safety - Remove global logger, each Application gets its own Logger instance - Fix X-Forwarded-For parsing to extract first IP from comma-separated list - Use standard log package in util.go instead of removed global logger
- Logger middleware now uses ctx.App.Logger instead of fmt.Printf - Add cachedMiddlewares to Group to avoid repeated slice allocations - Add RunGraceful() method for graceful shutdown with signal handling
- Mark ParamString() and QueryString() as deprecated
- Replace interface{} with any for Go 1.18+ consistency
- Use dynamic port allocation in tests to avoid conflicts
- Remove unused isValidHTTPMethod function and its tests
- Add tests for Shutdown and RunGraceful methods - Add tests for Logger middleware - Add tests for remoteAddr with various headers - Add tests for router search functionality - Add tests for response flush with cookies and redirect - Add tests for XML, context data, cookies, headers, queries - Add tests for success/fail responses and body operations - Fix acquireContext to initialize data field for sync.Pool - Add coverage_test.go with comprehensive test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces a major refactoring of the Lightning framework, improving reliability, performance, and developer experience. Test coverage has been increased from 81.2% to 90.9%.
Changes
✨ New Features
Run(),RunListener(),Shutdown(), andRunGraceful()methods with automatic signal handling (SIGINT/SIGTERM)sync.Poolfor Context reuse, significantly reducing GC pressureMaxRequestBodySizeconfiguration optiontruetofalse— setConfig.Debug = trueexplicitly if needed🐛 Bug Fixes
🔄 Other Improvements
interface{}withanythroughout the codebasectx.App.Logger.Info()instead offmt.PrintfTest Results
Commits
27e8f74fix: resolve P1 performance and security issuese74f830fix: resolve P2 design and functionality issuesbcb6b97fix: resolve P3 code quality issues75c58f2test: improve test coverage from 81.2% to 90.9%b350239docs: update CHANGELOG for v0.8.0 release