🚸 Add log middleware to basic template#124
🚸 Add log middleware to basic template#124valentimarco wants to merge 1 commit intogofiber:masterfrom
Conversation
WalkthroughThe changes in the pull request primarily enhance the functionality of the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
cmd/new.go (1)
Line range hint
82-116: Consider documenting the logger middleware featureThe basic template now includes a logger middleware by default, but this isn't reflected in the examples or documentation. Consider adding a note about this feature to help users understand what's included in the generated project.
Here's a suggested addition to the examples:
fiber new fiber-demo - Generates a project with go module name fiber-demo + Generates a project with go module name fiber-demo (includes request logging middleware)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
cmd/new.go(1 hunks)
🔇 Additional comments (1)
cmd/new.go (1)
138-145: LGTM! Logger middleware integration looks good.
The logger middleware is correctly imported and properly registered at the application level, ensuring all requests will be logged. This will help developers during the development process by providing visibility into incoming requests.
| }) | ||
|
|
||
| log.Fatal(app.Listen(":3000")) | ||
| app.Listen(":3000") |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add error handling for the server startup
The app.Listen() call should include error handling to prevent silent failures.
Here's the suggested improvement:
- app.Listen(":3000")
+ if err := app.Listen(":3000"); err != nil {
+ log.Fatal(err)
+ }Don't forget to add the log package to the imports:
+ "log"Committable suggestion skipped: line range outside the PR's diff.
| }) | ||
|
|
||
| log.Fatal(app.Listen(":3000")) | ||
| app.Listen(":3000") |
There was a problem hiding this comment.
The log fatal is needed else you won't see why it failed.
| func main() { | ||
| app := fiber.New() | ||
| app := fiber.New() | ||
| app.Use(logger.New()) |
There was a problem hiding this comment.
This does add overhead, probably why the default server doesnt have it
There was a problem hiding this comment.
I think is useful to have it, maybe i can add a check for a env like "DEBUG" and activate only when the enviroment is develop?
Please provide enough information so that others can review your pull request:
As title
Explain the details for making this change. What existing problem does the pull request solve?
The logging middleware can help a lot when developing
Summary by CodeRabbit
newcommand for generating Fiber projects with improved templates.