Skip to content
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

📚 Docs: Add c.Drop() example to whats_new.md #3285

Merged
merged 2 commits into from
Jan 19, 2025

Conversation

grivera64
Copy link
Member

Description

This PR adds a Drop section with an example in whats_new.md. It also reorders c.Drop() and c.End() in whats_new.md to match the source code order.

Fixes #3282

Changes introduced

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.
  • Documentation Update: Detail the updates made to the documentation and links to the changed files.
  • Changelog/What's New: Include a summary of the additions for the upcoming release notes.
  • Migration Guide: If necessary, provide a guide or steps for users to migrate their existing code to accommodate these changes.
  • API Alignment with Express: Explain how the changes align with the Express API.
  • API Longevity: Discuss the steps taken to ensure that the new or updated APIs are consistent and not prone to breaking changes.
  • Examples: Provide examples demonstrating the new features or changes in action.

Type of change

  • Documentation update (changes to documentation)

Checklist

Before you submit your pull request, please make sure you meet these requirements:

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

Commit formatting

Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md

- Add Drop section with an example in `whats_new.md`
- Reorder `c.Drop()` and `c.End()` to match source code order
  in `whats_new.md`
@grivera64 grivera64 requested a review from a team as a code owner January 19, 2025 00:58
@grivera64 grivera64 requested review from gaby, sixcolors, ReneWerner87 and efectn and removed request for a team January 19, 2025 00:58
Copy link
Contributor

coderabbitai bot commented Jan 19, 2025

Warning

Rate limit exceeded

@gaby has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 34 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1dedc80 and 927e3b3.

📒 Files selected for processing (1)
  • docs/whats_new.md (2 hunks)

Walkthrough

The pull request introduces significant updates to the Fiber framework version 3, focusing on refactoring method signatures and enhancing framework functionality. The changes primarily affect the Router and Ctx interfaces, modifying HTTP method registrations, test configurations, and introducing new methods like Drop() and End(). The updates aim to provide a more explicit and flexible API, with improved method chaining and context management.

Changes

File Changes
router.go Updated HTTP method signatures (Get, Post, Put, etc.) to separate primary handler and middleware
app.go Modified Test() method to accept TestConfig, updated NewCtxFunc signature
ctx.go Added new methods Drop() and End()

Assessment against linked issues

Objective Addressed Explanation
Add ctx.Drop() to whats_new.md [#3282]

Possibly related PRs

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • efectn

Poem

🐰 In Fiber's realm of code so bright,
Methods dance with newfound might,
Drop and End, a rabbit's glee,
Refactoring with agility!
Version 3 hops with pure delight! 🚀


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/whats_new.md (2)

408-438: LGTM! Documentation for Drop() is clear and well-structured.

The documentation effectively explains the purpose, use cases, and implementation of the Drop() function. The caution note about additional security measures is particularly valuable.

Consider adding a note about error handling, specifically mentioning that Drop() returns nil and can be used with or without the return statement:

 app.Get("/", func(c fiber.Ctx) error {
   if c.IP() == "192.168.1.1" {
-    return c.Drop()
+    c.Drop() // Both with or without return statement work
+    return nil
   }

   return c.SendString("Hello World!")
 })

Line range hint 439-476: LGTM! Documentation for End() is comprehensive and well-explained.

The documentation effectively explains the purpose and usage of the End() function, particularly in the context of middleware chains.

Consider adding a note about the order of operations when using End() with SendString, specifically mentioning that the response is sent before the connection is closed:

 app.Get("/hello", func (c fiber.Ctx) error {
     query := c.Query("name", "")
     if query == "" {
-        c.SendString("You don't have a name?")
-        c.End()
+        c.SendString("You don't have a name?") // Response is sent first
+        c.End() // Then the connection is closed
         return errors.New("No name provided")
     }
     return c.SendString("Hello, " + query + "!")
 })
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 156897e and 1dedc80.

📒 Files selected for processing (1)
  • docs/whats_new.md (2 hunks)

Copy link
Member

@gaby gaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@gaby gaby added this to the v3 milestone Jan 19, 2025
@gaby gaby merged commit aa245ae into gofiber:main Jan 19, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🧹 [Maintenance]: Add ctx.Drop() to whats_new.md
3 participants