Skip to content

📒 docs: Refresh adaptor middleware guidance#3981

Merged
ReneWerner87 merged 9 commits into
mainfrom
update-adaptor-documentation-and-examples
Jan 5, 2026
Merged

📒 docs: Refresh adaptor middleware guidance#3981
ReneWerner87 merged 9 commits into
mainfrom
update-adaptor-documentation-and-examples

Conversation

@gaby
Copy link
Copy Markdown
Member

@gaby gaby commented Jan 4, 2026

Summary

  • Document the adaptor middleware’s 10 MiB net/http body limit and clarify API coverage
  • Add dedicated usage examples for each adaptor helper, including ConvertRequest server usage and CopyContextToFiberContext context propagation
  • Restore user-friendly example section titles while keeping per-function coverage explicit

Fixes #3980

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 4, 2026

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

Adds adaptor functionality to copy arbitrary context values into a fasthttp.RequestCtx, documents a 10 MiB incoming-body limit (returns 413 when exceeded), updates examples and deprecation guidance, and changes CopyContextToFiberContext to accept any for broader compatibility.

Changes

Cohort / File(s) Summary
Adaptor docs
docs/middleware/adaptor.md
Expanded usage examples (net/http ↔ Fiber flows), added ConvertRequest and CopyContextToFiberContext usage, noted deprecation and unsafe-reflection guidance, and documented 10 MiB body-size limit/413 behavior.
Middleware / adaptor package
.../middleware/adaptor, github.com/gofiber/fiber/v3/middleware/adaptor
Public API change: CopyContextToFiberContext(context any, requestContext *fasthttp.RequestCtx) (was context.Context). Implementation updated to accept generic sources and copy context values into fasthttp.RequestCtx; handles wrapped requests and enforces body-copying limit.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant NetHTTP as net/http Server
  participant Adaptor as adaptor.CopyContextToFiberContext
  participant FiberCtx as fasthttp.RequestCtx
  Note right of NetHTTP: Incoming HTTP request may carry context values and body
  Client->>NetHTTP: HTTP request (with context values, body)
  NetHTTP->>Adaptor: ConvertRequest / CopyContextToFiberContext(context:any, requestCtx)
  Adaptor->>FiberCtx: Inject copied values into RequestCtx
  Adaptor->>FiberCtx: Copy request body (capped at 10 MiB)
  alt body <= 10 MiB and injection succeeds
    FiberCtx->>FiberCtx: Fiber handler reads values and processes
    FiberCtx-->>NetHTTP: Handler response forwarded
  else body > 10 MiB
    Adaptor-->>NetHTTP: Return 413 Payload Too Large
  else unsupported/failed injection
    Adaptor-->>NetHTTP: No-op (values not injected)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • sixcolors
  • ReneWerner87
  • efectn

Poem

🐇 I hopped through code at break of day,

I nudged some contexts on their way.
From net/http to Fiber’s door,
I stitched the values—now they soar.
Tiny hop, big integration score 🥕

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: a documentation refresh of adaptor middleware guidance, which aligns with the file modified (docs/middleware/adaptor.md).
Description check ✅ Passed The description covers the summary, references the fixed issue (#3980), and explains the key documentation improvements made, though it doesn't fully address all template sections like benchmarks or migration guides.
Linked Issues check ✅ Passed The PR successfully addresses issue #3980 by documenting the 10 MiB body limit, providing dedicated usage examples for each adaptor helper (ConvertRequest, CopyContextToFiberContext), and clarifying API coverage for using Fiber handlers in net/http projects.
Out of Scope Changes check ✅ Passed All changes are within scope of the PR objectives: documentation updates to docs/middleware/adaptor.md and the API signature change to CopyContextToFiberContext directly support the linked issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 @gaby, 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 significantly refines the documentation for Fiber's adaptor middleware. The changes focus on providing crucial information regarding body size limits when integrating Fiber with net/http, offering more detailed and explicit usage examples for various adaptor functions, and improving the overall structure and clarity of the documentation sections. The goal is to ensure developers have a clearer understanding of how to effectively use the adaptor middleware for seamless interoperability between Fiber and net/http components.

Highlights

  • Body Size Limit Documentation: Added a clear note detailing the 10 MiB net/http body limit when Fiber is executed from a net/http server through adaptor functions, and the resulting 413 error for exceeding this limit.
  • Enhanced Usage Examples: Introduced dedicated and more comprehensive usage examples for each adaptor helper, including ConvertRequest for server usage and CopyContextToFiberContext for context propagation.
  • Improved Documentation Clarity: Restored user-friendly example section titles while maintaining explicit per-function coverage, making the documentation easier to navigate and understand.
  • New CopyContextToFiberContext Example: Provided a new example demonstrating how to use CopyContextToFiberContext to transfer values from a context.Context to a fasthttp.RequestCtx, along with a note about its deprecated status due to reflection and unsafe operations.
  • ConvertRequest Server Usage: Updated the ConvertRequest example to correctly use the forServer=true parameter and illustrate how the converted request can be passed to a net/http handler.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@ReneWerner87 ReneWerner87 added this to the v3 milestone Jan 4, 2026
@ReneWerner87 ReneWerner87 added this to v3 Jan 4, 2026
@gaby gaby changed the title 📒 docs: refresh adaptor middleware guidance 📒 docs: Refresh adaptor middleware guidance Jan 4, 2026
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 significantly improves the documentation for the adaptor middleware. The changes clarify API coverage, introduce a crucial note about body size limits, and provide comprehensive usage examples for each adaptor helper, including ConvertRequest and CopyContextToFiberContext. The updated section titles also enhance readability and navigation. Overall, these updates make the adaptor documentation much more informative and user-friendly.

@gaby gaby marked this pull request as ready for review January 4, 2026 02:09
@gaby gaby requested a review from a team as a code owner January 4, 2026 02:09
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 refreshes the adaptor middleware documentation by documenting the 10 MiB body size limit for Fiber handlers running in net/http servers, adding dedicated usage examples for each adaptor helper function, and improving section titles for clarity.

Key Changes:

  • Documents the 10 MiB body size limit that applies when Fiber executes from a net/http server
  • Adds two new usage examples: one for FiberHandlerFunc and one for CopyContextToFiberContext
  • Updates all example section titles to explicitly reference the adaptor functions being demonstrated

Comment thread docs/middleware/adaptor.md
Comment thread docs/middleware/adaptor.md
Comment thread docs/middleware/adaptor.md
Comment thread docs/middleware/adaptor.md
Comment thread docs/middleware/adaptor.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: 1

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7c2862 and 761723b.

📒 Files selected for processing (1)
  • docs/middleware/adaptor.md
🧰 Additional context used
📓 Path-based instructions (2)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Review and update the contents of the docs folder if necessary when modifying code

Files:

  • docs/middleware/adaptor.md
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (8)
📓 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: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • docs/middleware/adaptor.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/middleware/adaptor.md
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-13T00:19:16.407Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3446
File: docs/middleware/logger.md:44-44
Timestamp: 2025-05-13T00:19:16.407Z
Learning: In documentation files for the Fiber framework, code examples are often partial and don't repeat import statements that were shown in earlier examples, focusing instead on demonstrating specific usage patterns.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-09-25T15:57:10.221Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • docs/middleware/adaptor.md
🪛 LanguageTool
docs/middleware/adaptor.md

[grammar] ~203-~203: Ensure spelling is correct
Context: ...passed into a net/http handler so the adaptor sets server-oriented fields correctly: ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (4)
docs/middleware/adaptor.md (4)

24-35: Body size limit documentation is clear and well‑placed.

The new caution note (lines 31–35) properly documents the 10 MiB net/http body limit when Fiber runs through FiberHandler, FiberHandlerFunc, or FiberApp. This is critical information for users and is positioned appropriately in the Features section.


200-234: Example 6 (ConvertRequest) is comprehensive and correct.

The example demonstrates ConvertRequest with the forServer parameter set correctly (true), and the pattern of converting a Fiber context to an http.Request for use with net/http handlers is sound. The use of httptest.NewRecorder() is idiomatic.


54-88: Example 1 improvements enhance clarity.

The updated example now clearly shows three patterns: auto-adaptation by Fiber, manual conversion with caching, and direct conversion via HTTPHandlerFunc. The explanatory comments improve readability.


1-282: Markdown linting should be run per coding guidelines.

According to the coding guidelines, you should run make markdown to lint all Markdown files when modifying code. Please verify that all Markdown formatting is correct after your changes.

Comment thread docs/middleware/adaptor.md
gaby and others added 4 commits January 3, 2026 21:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removed deprecated section about CopyContextToFiberContext and its usage example.
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread docs/middleware/adaptor.md
Comment thread docs/middleware/adaptor.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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/middleware/adaptor.md (2)

39-48: Add a usage example for CopyContextToFiberContext.

The API Reference documents CopyContextToFiberContext with its updated signature (accepting any instead of context.Context), but there is no corresponding usage example. The PR objectives explicitly state: "Add dedicated usage examples for each adaptor helper, including... CopyContextToFiberContext context propagation."

Add a new example section (e.g., Example 7) demonstrating how to copy values from a context.Context into a fasthttp.RequestCtx, showing a realistic scenario such as propagating request-scoped values (trace IDs, user info) from net/http context to Fiber context.

Would you like me to generate an example demonstrating CopyContextToFiberContext usage, such as extracting a trace ID from context and making it available in the Fiber handler?


1-234: Fix markdown linting violations (16 line-length errors).

The file fails markdown linting with 16 MD013/line-length violations. Lines 7, 18–20, 33, 39, 41–49, 56, and 246 exceed the 80-character limit, with the API Reference table rows (lines 39–49) being the most severely over-length at 178 characters each. Reformat these lines to comply with the 80-character limit.

♻️ Duplicate comments (1)
docs/middleware/adaptor.md (1)

26-29: Add periods to list items for consistency.

List items should end with periods. Currently, lines 26-29 lack punctuation at the end of each bullet point.

- Convert `net/http` handlers and middleware to Fiber handlers
- Convert Fiber handlers to `net/http` handlers
- Convert a Fiber context (`fiber.Ctx`) into an `http.Request`
- Copy values stored in a `context.Context` onto a `fasthttp.RequestCtx`
+ Convert `net/http` handlers and middleware to Fiber handlers.
+ Convert Fiber handlers to `net/http` handlers.
+ Convert a Fiber context (`fiber.Ctx`) into an `http.Request`.
+ Copy values stored in a `context.Context` onto a `fasthttp.RequestCtx`.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfdde2e and 444ebb3.

📒 Files selected for processing (1)
  • docs/middleware/adaptor.md
🧰 Additional context used
📓 Path-based instructions (2)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Review and update the contents of the docs folder if necessary when modifying code

Files:

  • docs/middleware/adaptor.md
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (11)
📓 Common learnings
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
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: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • docs/middleware/adaptor.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/middleware/adaptor.md
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-09-25T15:57:10.221Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/session_manager.go:30-43
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the session middleware, `session.FromContext(c)` returns `*session.Middleware`, whereas `m.session.Get(c)` returns `*session.Store`, so they are not directly interchangeable.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-13T00:19:16.407Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3446
File: docs/middleware/logger.md:44-44
Timestamp: 2025-05-13T00:19:16.407Z
Learning: In documentation files for the Fiber framework, code examples are often partial and don't repeat import statements that were shown in earlier examples, focusing instead on demonstrating specific usage patterns.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-07T13:07:33.899Z
Learnt from: mdelapenya
Repo: gofiber/fiber PR: 3434
File: docs/api/services.md:39-43
Timestamp: 2025-05-07T13:07:33.899Z
Learning: When documenting Go interface methods in the Fiber project, avoid showing method signatures with the interface type as the receiver (e.g., `func (d *Service) Method()`) since interfaces cannot be used as receivers in Go. Instead, show just the method signature without a receiver or use a placeholder implementation name.

Applied to files:

  • docs/middleware/adaptor.md
🪛 LanguageTool
docs/middleware/adaptor.md

[grammar] ~203-~203: Ensure spelling is correct
Context: ...passed into a net/http handler so the adaptor sets server-oriented fields correctly: ...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cleanup artifacts

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 4, 2026

@gaby I've opened a new pull request, #3982, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits January 4, 2026 05:01
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
docs: Clarify forServer parameter usage in ConvertRequest documentation
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

♻️ Duplicate comments (1)
docs/middleware/adaptor.md (1)

153-174: Remove redundant Section 4—FiberHandlerFunc is already demonstrated in Section 3.

Section 3 demonstrates both FiberHandler and FiberHandlerFunc together (lines 140–143), including the line http.HandleFunc("/func", adaptor.FiberHandlerFunc(helloFiber)). Section 4 (lines 153–174) repeats the same FiberHandlerFunc pattern in isolation without introducing new concepts, use cases, or meaningful distinctions. Remove Section 4 to eliminate duplication and maintain documentation conciseness.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 444ebb3 and a3936f5.

📒 Files selected for processing (1)
  • docs/middleware/adaptor.md
🧰 Additional context used
📓 Path-based instructions (2)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Review and update the contents of the docs folder if necessary when modifying code

Files:

  • docs/middleware/adaptor.md
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (11)
📓 Common learnings
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
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: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • docs/middleware/adaptor.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/middleware/adaptor.md
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-09-25T16:18:34.719Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-09-25T16:18:34.719Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-09-25T15:57:10.221Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-09-25T15:57:10.221Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/session_manager.go:30-43
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the session middleware, `session.FromContext(c)` returns `*session.Middleware`, whereas `m.session.Get(c)` returns `*session.Store`, so they are not directly interchangeable.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-13T00:19:16.407Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3446
File: docs/middleware/logger.md:44-44
Timestamp: 2025-05-13T00:19:16.407Z
Learning: In documentation files for the Fiber framework, code examples are often partial and don't repeat import statements that were shown in earlier examples, focusing instead on demonstrating specific usage patterns.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-07T13:07:33.899Z
Learnt from: mdelapenya
Repo: gofiber/fiber PR: 3434
File: docs/api/services.md:39-43
Timestamp: 2025-05-07T13:07:33.899Z
Learning: When documenting Go interface methods in the Fiber project, avoid showing method signatures with the interface type as the receiver (e.g., `func (d *Service) Method()`) since interfaces cannot be used as receivers in Go. Instead, show just the method signature without a receiver or use a placeholder implementation name.

Applied to files:

  • docs/middleware/adaptor.md
🔇 Additional comments (2)
docs/middleware/adaptor.md (2)

31-35: ✅ Body size limit documentation is clear and accurate.

The note correctly documents the 10 MiB limit for request bodies when Fiber is executed from net/http via FiberHandler, FiberHandlerFunc, or FiberApp. The title "Body size limits when running Fiber from net/http" is now unambiguous and aligns with PR objectives. The 413 response code is appropriately documented.


200-209: ConvertRequest example and forServer parameter documentation are well-balanced.

The explanation clearly distinguishes between forServer = true (server-side handling) and forServer = false (client-side use), and the example demonstrates the server-side case with practical context (using httptest.NewRecorder and http.DefaultServeMux). This addresses prior feedback about clarifying the parameter's practical usage.

Comment thread docs/middleware/adaptor.md
Document the deprecated CopyContextToFiberContext function and provide usage example.
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/middleware/adaptor.md (1)

153-174: Consider consolidating Section 4 with Section 3 to avoid duplication.

Section 3 (lines 125–151) already demonstrates adaptor.FiberHandlerFunc on line 143. Section 4 (lines 153–174) repeats nearly identical code without introducing meaningfully new information. While the section title emphasizes "when you specifically need an http.HandlerFunc," this context is already established in Section 3. For a "Chill" review, this is optional, but consider whether Section 4 adds sufficient pedagogical value or should be merged into Section 3 with a note on the difference between http.Handle and http.HandleFunc.

📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3936f5 and 8f98275.

📒 Files selected for processing (1)
  • docs/middleware/adaptor.md
🧰 Additional context used
📓 Path-based instructions (2)
docs/**

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Review and update the contents of the docs folder if necessary when modifying code

Files:

  • docs/middleware/adaptor.md
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (11)
📓 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: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.

Applied to files:

  • docs/middleware/adaptor.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/middleware/adaptor.md
📚 Learning: 2024-11-08T04:10:42.990Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/cache/cache_test.go:897-897
Timestamp: 2024-11-08T04:10:42.990Z
Learning: In the Fiber framework, `Context()` is being renamed to `RequestCtx()`, and `UserContext()` to `Context()` to improve clarity and align with Go's context conventions.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-11-15T07:56:21.623Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/config.go:122-122
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In `DefaultErrorHandler(c *fiber.Ctx, err error)`, since `c` is a pointer to an interface, we need to dereference `*c` when calling interface methods like `SendStatus`.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/csrf_test.go:188-193
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the Fiber framework tests, using `ctx.Response.Header.Cookie` may not be suitable for parsing cookies from the response header, as it requires a `*Cookie` and fills it rather than returning a string value; thus, manual parsing of the `Set-Cookie` header may be necessary.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/csrf/session_manager.go:30-43
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In the session middleware, `session.FromContext(c)` returns `*session.Middleware`, whereas `m.session.Get(c)` returns `*session.Store`, so they are not directly interchangeable.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-13T00:19:16.407Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3446
File: docs/middleware/logger.md:44-44
Timestamp: 2025-05-13T00:19:16.407Z
Learning: In documentation files for the Fiber framework, code examples are often partial and don't repeat import statements that were shown in earlier examples, focusing instead on demonstrating specific usage patterns.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-10-16T07:19:52.418Z
Learnt from: grivera64
Repo: gofiber/fiber PR: 3807
File: adapter_test.go:118-144
Timestamp: 2025-10-16T07:19:52.418Z
Learning: In the Fiber codebase, the linter does not allow `require` assertions from within HTTP handlers (including net/http-style handlers). Use `t.Fatalf`, `t.Errorf`, or similar `testing.T` methods for error handling inside handler functions instead.

Applied to files:

  • docs/middleware/adaptor.md
📚 Learning: 2025-05-07T13:07:33.899Z
Learnt from: mdelapenya
Repo: gofiber/fiber PR: 3434
File: docs/api/services.md:39-43
Timestamp: 2025-05-07T13:07:33.899Z
Learning: When documenting Go interface methods in the Fiber project, avoid showing method signatures with the interface type as the receiver (e.g., `func (d *Service) Method()`) since interfaces cannot be used as receivers in Go. Instead, show just the method signature without a receiver or use a placeholder implementation name.

Applied to files:

  • docs/middleware/adaptor.md
🔇 Additional comments (5)
docs/middleware/adaptor.md (5)

31-35: Approve body size limit documentation.

The note clearly documents the 10 MiB cap and 413 status, with proper formatting and punctuation. The title "Body size limits when running Fiber from net/http" accurately describes the direction of the wrapping.


200-239: Approve ConvertRequest example with clear forServer guidance.

The example effectively demonstrates both forServer parameter options with clear comments explaining when to use each value. The use of httptest.NewRecorder and c.RequestCtx() method aligns with Fiber v3 conventions.


241-287: Approve CopyContextToFiberContext example; address status code selection.

The example now demonstrates the full workflow requested in PR objectives: creating a context.Context, converting Fiber context to http.Request, enriching context, and copying values back. However, line 282 returns fiber.StatusNotFound when the context value is missing, which is misleading—a missing context value indicates a middleware execution or propagation issue, not a missing resource. Consider returning fiber.StatusInternalServerError instead.

🔎 Proposed fix for status code selection
-        return c.SendStatus(fiber.StatusNotFound)
+        return c.SendStatus(fiber.StatusInternalServerError)
Based on learnings, `c.Context()` correctly replaces the deprecated `c.UserContext()` method for accessing the Go standard `context.Context` in Fiber v3.

48-48: The CopyContextToFiberContext signature in the documentation is accurate.

The implementation in middleware/adaptor/adaptor.go:73 confirms the function accepts src any (matching the documented context any type), reflecting the intentional design for Fiber v3 to support flexible context handling during the framework's migration to improved context conventions.


29-29: The file already maintains consistent punctuation across all bullet lists—none of the bullet points throughout docs/middleware/adaptor.md use terminal periods. This is an intentional file-wide style, not an inconsistency requiring correction.

Likely an incorrect or invalid review comment.

@ReneWerner87 ReneWerner87 merged commit 5b3f139 into main Jan 5, 2026
4 checks passed
@ReneWerner87 ReneWerner87 deleted the update-adaptor-documentation-and-examples branch January 5, 2026 11:12
@github-project-automation github-project-automation Bot moved this to Done in v3 Jan 5, 2026
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.

📝 [Proposal]: Adapter for Fiber Handler to be used in net/http

4 participants