-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
add ghttp server start hooks #4474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds server lifecycle hooks to the ghttp server, allowing developers to register callback functions that execute at specific points during server startup. The implementation provides both "before start" hooks for initialization tasks that can prevent server startup if they fail, and "after start" hooks for post-startup tasks that are executed after the server is successfully running.
Key changes:
- Added
SetBeforeStart()
andSetAfterStart()
methods to register lifecycle hooks - Integrated hook execution into the server startup process with proper error handling
- Added comprehensive test coverage for various hook scenarios including error handling and execution order
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
net/ghttp/ghttp.go |
Added ServerHookFunc type and hook storage fields to the Server struct |
net/ghttp/ghttp_server_lifecycle_hooks.go |
Implemented the lifecycle hook methods and execution logic |
net/ghttp/ghttp_server.go |
Integrated hook execution into the server startup process |
net/ghttp/ghttp_z_unit_feature_lifecycle_hooks_test.go |
Added comprehensive unit tests for lifecycle hook functionality |
net/ghttp/example_lifecycle_hooks_test.go |
Added example code demonstrating hook usage patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
add ghttp server start hooks