Skip to content

📚 Doc: Clarify handler execution order and usage in Add()#3890

Merged
ReneWerner87 merged 3 commits into
gofiber:mainfrom
haikalSusanto:docs/enhance-docs-apps
Nov 24, 2025
Merged

📚 Doc: Clarify handler execution order and usage in Add()#3890
ReneWerner87 merged 3 commits into
gofiber:mainfrom
haikalSusanto:docs/enhance-docs-apps

Conversation

@haikalSusanto
Copy link
Copy Markdown
Contributor

@haikalSusanto haikalSusanto commented Nov 22, 2025

Description

This PR gives clearer explanation on handler execution order of Add()

Fixes #3885

Changes introduced

List the new features or adjustments introduced in this pull request. Provide details on benchmarks, documentation updates, changelog entries, and if applicable, the migration guide.

  • 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

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Enhancement (improvement to existing features and functionality)
  • Documentation update (changes to documentation)
  • Performance improvement (non-breaking change which improves efficiency)
  • Code consistency (non-breaking change which improves code reliability and robustness)

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 22, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Added/updated documentation comments for the routing Add handlers in multiple files to clarify execution order: the initial (non-variadic) handler runs first, followed by the variadic handlers in sequence.

Changes

Cohort / File(s) Change Summary
Docs
docs/partials/routing/handler.md
Added a documentation note describing handler execution order: the initial (non-variadic) handler executes first, then variadic handlers run in the provided order.
Code comments
app.go, group.go, register.go
Added/updated documentation comments on Add methods to clarify the same handler execution ordering; no signature, logic, or control-flow changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Documentation-only edits; no functional changes. No additional focus areas required.

Possibly related PRs

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • gaby

Poem

🐇 I hopped through docs with ink so light,
First the main handler, then the rest take flight.
A tiny note to set the order clear,
Little rabbit cheers — the path is near! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR only adds documentation comments about handler execution order but does not fix the actual bug: middlewares attached to handlers are still ignored [#3885]. Implement the fix to ensure variadic middlewares execute in the correct order with handlers, add test cases validating the fix, and update documentation accordingly.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: clarifying documentation for handler execution order in Add().
Description check ✅ Passed The description is partially complete with issue reference and documentation updates checked, but lacks details on what documentation was changed and leaves many template sections unchecked.
Out of Scope Changes check ✅ Passed All changes are documentation comments in routing files clarifying handler execution order, which are in scope for issue #3885.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @haikalSusanto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the clarity of the documentation for the Add() function, specifically detailing the sequence in which handlers are executed. This ensures that users have a precise understanding of how their handlers will be processed when utilizing this routing method.

Highlights

  • Documentation Update: Clarified the execution order of handlers for the Add() function within the routing documentation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request clarifies the execution order of handlers for the Add method in the documentation. The change is accurate and helpful. I've suggested a minor wording improvement to make the comment more concise and easier to understand by referencing the function's parameter names directly.

Comment thread docs/partials/routing/handler.md Outdated
Copy link
Copy Markdown
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 (1)
docs/partials/routing/handler.md (1)

23-25: Clear and accurate documentation for handler execution order.

The new documentation comments effectively clarify that the first (non-variadic) handler executes before the variadic handlers in order. This is helpful for users understanding the behavior of the Add() method.

Optional follow-up: The other HTTP methods (Get, Head, Post, Put, Delete, etc. at lines 12–20) have identical signatures and thus follow the same execution order. Consider adding similar documentation to those methods in a future update for completeness and consistency.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5caa478 and 8ae32fd.

📒 Files selected for processing (1)
  • docs/partials/routing/handler.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ckoch786
Repo: gofiber/fiber PR: 3230
File: docs/whats_new.md:944-951
Timestamp: 2024-12-15T19:56:45.935Z
Learning: Detailed usage examples and explanations for new methods like `RemoveRoute` and `RemoveRouteByName` are documented in `docs/api/app.md`, so it's unnecessary to duplicate them in `docs/whats_new.md`.
📚 Learning: 2025-10-16T07:15:26.529Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.

Applied to files:

  • docs/partials/routing/handler.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Comment thread docs/partials/routing/handler.md
Copy link
Copy Markdown
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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5493629 and a4941fe.

📒 Files selected for processing (3)
  • app.go (1 hunks)
  • group.go (1 hunks)
  • register.go (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • app.go
  • register.go
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:15:26.529Z
Learning: In Fiber v3, net/http handlers (http.Handler, http.HandlerFunc, or raw func(http.ResponseWriter, *http.Request)) can be passed directly to routing methods like app.Get(), app.Post(), etc. The framework automatically detects and wraps them internally via toFiberHandler/collectHandlers. The github.com/gofiber/fiber/v3/middleware/adaptor package is legacy and should not be suggested for tests or code using native net/http handler support.
Learnt from: ckoch786
Repo: gofiber/fiber PR: 3230
File: docs/whats_new.md:944-951
Timestamp: 2024-12-15T19:56:45.935Z
Learning: Detailed usage examples and explanations for new methods like `RemoveRoute` and `RemoveRouteByName` are documented in `docs/api/app.md`, so it's unnecessary to duplicate them in `docs/whats_new.md`.
🔇 Additional comments (1)
group.go (1)

168-176: LGTM! Implementation matches the documentation.

The implementation correctly preserves handler execution order by appending the primary handler before the variadic handlers (line 169). This ensures they execute in the documented sequence during request processing.

Note: Verification of the execution order was requested in the previous comment on line 167.

Comment thread group.go
@ReneWerner87 ReneWerner87 merged commit 7abd65c into gofiber:main Nov 24, 2025
2 checks passed
@welcome
Copy link
Copy Markdown

welcome Bot commented Nov 24, 2025

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@github-project-automation github-project-automation Bot moved this to Done in v3 Nov 24, 2025
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.

🐛 [Bug]: middlewares attached to handlers are ignored

4 participants