π₯ feat: Add local context support to adaptor middleware#3975
π₯ feat: Add local context support to adaptor middleware#3975ReneWerner87 merged 24 commits intogofiber:mainfrom
Conversation
WalkthroughStores Fiber's UserContext into the underlying fasthttp request context before invoking an adapted net/http handler and adds a helper to retrieve that stored context from an *http.Request; existing HTTPHandler remains unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client
participant FiberApp as Fiber app
participant Middleware as Fiber middleware
participant Adaptor as adaptor.HTTPHandlerWithContext
participant Fasthttp as fasthttp.RequestCtx
participant NetHTTP as net/http Handler
Client->>FiberApp: HTTP request
FiberApp->>Middleware: middleware sets c.SetUserContext(ctx)
FiberApp->>Adaptor: route invokes adapted handler with *fiber.Ctx
Adaptor->>Fasthttp: store c.UserContext() under localContextKey in request context
Adaptor->>NetHTTP: call ServeHTTP(w, r) (r.Context carries fasthttp context)
NetHTTP->>NetHTTP: call LocalContextFromHTTPRequest(r) to retrieve stored user context
NetHTTP->>Client: respond using values from retrieved context
Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checksβ Failed checks (1 warning)
β Passed checks (4 passed)
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. Comment |
Summary of ChangesHello @TheAspectDev, 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 addresses a critical limitation in the Fiber framework's adaptor middleware, specifically concerning the propagation of the local Fiber context to standard net/http handlers. By embedding the Fiber context within the http.Request context, it ensures that all contextual data, such as user-specific information, remains accessible throughout the request lifecycle, even when transitioning between Fiber and net/http components. This change significantly enhances the flexibility and power of integrating existing net/http middleware and handlers within Fiber applications. Highlights
π§ 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 AssistThe 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
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 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
|
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3975 +/- ##
==========================================
+ Coverage 90.96% 91.07% +0.10%
==========================================
Files 119 119
Lines 10782 10852 +70
==========================================
+ Hits 9808 9883 +75
+ Misses 617 613 -4
+ Partials 357 356 -1
Flags with carried forward coverage won't be shown. Click here to find out more. β View full report in Codecov by Sentry. π New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request correctly adds the local fiber context to the request context for net/http handlers, making it accessible. My main feedback is to improve the implementation of the context key to follow best practices and avoid potential collisions, by using a custom type instead of a string. I've also suggested some improvements to the new test to make it more robust and easier to debug.
There was a problem hiding this comment.
Actionable comments posted: 0
π§Ή Nitpick comments (3)
middleware/adaptor/adaptor.go (2)
32-32: Consider a more conventional constant name and export it for user access.The constant name
__local_context__uses double underscores, which is unconventional in Go. Additionally, since users need to reference this key to retrieve the local context from adapted handlers (as shown in the test), consider:
- Exporting the constant with a clearer name (e.g.,
LocalContextKey)- Adding documentation explaining its purpose and usage
This would make the API more discoverable and prevent users from having to hard-code the magic string
"__local_context__".π Proposed refactor
-const ctxKey = "__local_context__" +// LocalContextKey is the key used to store the Fiber context in the fasthttp request context. +// Adapted http.Handler functions can retrieve the Fiber context using r.Context().Value(adaptor.LocalContextKey). +const LocalContextKey = "__local_context__"Then update the usage:
- c.RequestCtx().SetUserValue(ctxKey, c.Context()) + c.RequestCtx().SetUserValue(LocalContextKey, c.Context())
56-57: Enhance the comment to clarify what "local context" means.The comment mentions "local context" but it would be clearer to specify that this is the Fiber user context (from
c.Context()) being made available to the adapted net/http handler. This helps maintainers understand the purpose at a glance.π Proposed enhancement
- // add the local context inside of request context with the key `ctxKey` + // Store the Fiber user context (c.Context()) in the fasthttp request context + // so adapted net/http handlers can retrieve it via r.Context().Value(ctxKey) c.RequestCtx().SetUserValue(ctxKey, c.Context())middleware/adaptor/adaptor_test.go (1)
290-290: Replace magic string with exported constant.The test hard-codes
"__local_context__"which creates a maintenance burden if the key changes. If the constant is exported as suggested in the review ofadaptor.go, update this test to reference it.π Proposed refactor (assuming constant is exported)
- ctx, ok := r.Context().Value("__local_context__").(context.Context) + ctx, ok := r.Context().Value(LocalContextKey).(context.Context)
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π§° Additional context used
π Path-based instructions (2)
**/*_test.go
π CodeRabbit inference engine (AGENTS.md)
When adding Go tests, always invoke
t.Parallel()at the start of each test and subtest to maximize concurrency
Files:
middleware/adaptor/adaptor_test.go
**/*.go
π CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
middleware/adaptor/adaptor_test.gomiddleware/adaptor/adaptor.go
π§ Learnings (8)
π 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: 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: 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: arturmelanchyk
Repo: gofiber/fiber PR: 3768
File: client/request.go:162-166
Timestamp: 2025-09-28T17:39:26.644Z
Learning: In fasthttp-based code like gofiber, using utils.UnsafeString(key) instead of string(key) is acceptable when values are used immediately within the same call stack and not stored for later use, as it avoids allocations and aligns with fasthttp's zero-allocation design philosophy.
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.
π 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:
middleware/adaptor/adaptor_test.gomiddleware/adaptor/adaptor.go
π 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:
middleware/adaptor/adaptor_test.gomiddleware/adaptor/adaptor.go
π 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:
middleware/adaptor/adaptor_test.go
π Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.
Applied to files:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor.go
π Learning: 2025-09-28T17:39:26.644Z
Learnt from: arturmelanchyk
Repo: gofiber/fiber PR: 3768
File: client/request.go:162-166
Timestamp: 2025-09-28T17:39:26.644Z
Learning: In fasthttp-based code like gofiber, using utils.UnsafeString(key) instead of string(key) is acceptable when values are used immediately within the same call stack and not stored for later use, as it avoids allocations and aligns with fasthttp's zero-allocation design philosophy.
Applied to files:
middleware/adaptor/adaptor.go
𧬠Code graph analysis (1)
middleware/adaptor/adaptor_test.go (2)
ctx_interface_gen.go (1)
Ctx(18-435)middleware/adaptor/adaptor.go (1)
HTTPHandler(53-62)
β° 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). (5)
- GitHub Check: unit (1.25.x, macos-latest)
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: repeated
- GitHub Check: Compare
- GitHub Check: lint
π Additional comments (3)
middleware/adaptor/adaptor_test.go (2)
267-319: LGTM! Test properly validates local context propagation.The test correctly:
- Follows the
t.Parallel()guideline- Uses a unique type for the context key to avoid collisions
- Sets a value in the Fiber context via middleware
- Retrieves the value from the adapted handler via the request context
- Validates the complete flow
267-319: No duplicate test function exists.The search confirms only one occurrence of
Test_HTTPHandler_local_contextat line 267. The AI summary's claim about "two identical tests" is incorrect.middleware/adaptor/adaptor.go (1)
53-62: Verify this approach aligns with the linked issue's expectations.The implementation stores
c.Context()under a custom key in the fasthttp request context. According to issue #2711, users need to access values set viac.SetUserContext()from adapted handlers. Please confirm that:
- The fasthttp adaptor properly propagates user values set via
SetUserValueto the Gocontext.Contextreturned byr.Context()in the net/http handler- Users can successfully retrieve the Fiber context using
r.Context().Value("__local_context__")The test suggests this works, but it's worth verifying the fasthttp adaptor's behavior hasn't changed in recent versions.
#!/bin/bash # Check if there are any examples or documentation about SetUserValue and how it relates to r.Context() rg -n -C3 'SetUserValue.*Context|Context.*SetUserValue' --type=go
There was a problem hiding this comment.
Actionable comments posted: 0
β»οΈ Duplicate comments (1)
middleware/adaptor/adaptor_test.go (1)
291-293: Replacet.Fatalwitht.Errorfor HTTP error responses in handler.According to the Fiber codebase linter rules,
t.Fataland similar assertions from testing packages are not allowed within HTTP handlers (including net/http-style handlers). Uset.Errorfwith early returns or write HTTP error responses instead.Based on learnings from previous reviews on this codebase.
Proposed fix
ctx, ok := r.Context().Value(LocalContextKey).(context.Context) if !ok { - t.Fatal("local context not found in request context") + t.Errorf("local context not found in request context") + http.Error(w, "local context not found", http.StatusInternalServerError) + return } val, ok := ctx.Value(testKey).(string) if !ok { - t.Fatal("test value not found in local context") + t.Errorf("test value not found in local context") + http.Error(w, "test value not found", http.StatusInternalServerError) + return }Also applies to: 296-298
π§Ή Nitpick comments (1)
middleware/adaptor/adaptor.go (1)
61-64: Consider clarifying the comment about what's being stored.The comment states "Store the Fiber user context (c.Context())" but the implementation actually stores a wrapped context that contains both the user context values (inherited from the parent) and the Fiber context
cunderLocalContextKey. While the implementation is correct for the intended use case, the comment could be more precise about what's actually stored.Suggested comment clarification
- // Store the Fiber user context (c.Context()) in the fasthttp request context - // so adapted net/http handlers can retrieve it via r.Context().Value(LocalContextKey) + // Wrap the Fiber user context with LocalContextKey pointing to the Fiber context, + // allowing adapted net/http handlers to access both user context values and the Fiber context + // via r.Context().Value(LocalContextKey)
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π§° Additional context used
π Path-based instructions (2)
**/*.go
π CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
**/*_test.go
π CodeRabbit inference engine (AGENTS.md)
When adding Go tests, always invoke
t.Parallel()at the start of each test and subtest to maximize concurrency
Files:
middleware/adaptor/adaptor_test.go
π§ Learnings (9)
π 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: 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: 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.
π 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:
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π Learning: 2025-09-28T17:39:26.644Z
Learnt from: arturmelanchyk
Repo: gofiber/fiber PR: 3768
File: client/request.go:162-166
Timestamp: 2025-09-28T17:39:26.644Z
Learning: In fasthttp-based code like gofiber, using utils.UnsafeString(key) instead of string(key) is acceptable when values are used immediately within the same call stack and not stored for later use, as it avoids allocations and aligns with fasthttp's zero-allocation design philosophy.
Applied to files:
middleware/adaptor/adaptor.go
π 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:
middleware/adaptor/adaptor.gomiddleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor.go
π Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.
Applied to files:
middleware/adaptor/adaptor_test.go
β° 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). (3)
- GitHub Check: repeated
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: Compare
π Additional comments (1)
middleware/adaptor/adaptor.go (1)
33-37: LGTM! Context key follows Go best practices.The custom type
localCtxKeyfor the context key is the correct approach to avoid collisions between packages, as recommended in the Go context documentation. ExportingLocalContextKeyallows users to retrieve the stored context from adapted handlers.
|
Hey, is this benchmark related to the pr? |
Yeah, it's unrelated |
|
@codex review |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
π§Ή Nitpick comments (1)
middleware/adaptor/adaptor_test.go (1)
267-317: LGTM: Well-structured test for context propagation.The test properly validates that values set in Fiber middleware context are accessible to adapted net/http handlers via
LocalContextFromHTTPRequest. Good use of a unique context key type to avoid collisions, and appropriate error handling withhttp.Errorinstead oft.Fatalinside the handler.Optional: Consider removing t.Logf from handler
While the test is correct, Line 300 uses
t.Logfinside the HTTP handler. Thoughapp.Test()is synchronous and this should be safe, it's generally better to avoid calling test methods from within handlers. Consider simply ignoring the write error or handling it differently:w.Header().Set("Content-Type", "text/plain; charset=utf-8") w.WriteHeader(http.StatusOK) - if _, err := w.Write([]byte(val)); err != nil { - t.Logf("write failed: %v", err) - } + w.Write([]byte(val)) //nolint:errcheck // test response write })))
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
middleware/adaptor/adaptor_test.go
π§° Additional context used
π Path-based instructions (2)
**/*_test.go
π CodeRabbit inference engine (AGENTS.md)
When adding Go tests, always invoke
t.Parallel()at the start of each test and subtest to maximize concurrency
Files:
middleware/adaptor/adaptor_test.go
**/*.go
π CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
middleware/adaptor/adaptor_test.go
π§ Learnings (13)
π 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: 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: 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.
π 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:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor_test.go
π Learning: 2024-12-13T08:14:22.851Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: hooks_test.go:228-228
Timestamp: 2024-12-13T08:14:22.851Z
Learning: In Go test files, prefer using the `require` methods from the `testify` package for assertions instead of manual comparisons and calls to `t.Fatal` or `t.Fatalf`.
Applied to files:
middleware/adaptor/adaptor_test.go
π 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:
middleware/adaptor/adaptor_test.go
π Learning: 2024-07-26T21:00:12.902Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 2922
File: middleware/cors/utils.go:63-71
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The project uses the testify/assert package for assertions in unit tests.
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2024-10-02T23:03:31.727Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-02T23:03:31.727Z
Learning: Unit tests in this project use testify require.
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2025-12-07T15:07:23.885Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-07T15:07:23.885Z
Learning: Applies to **/*_test.go : When adding Go tests, always invoke `t.Parallel()` at the start of each test and subtest to maximize concurrency
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2024-11-29T12:37:27.581Z
Learnt from: efectn
Repo: gofiber/fiber PR: 3162
File: app_test.go:893-895
Timestamp: 2024-11-29T12:37:27.581Z
Learning: In the `Test_App_ShutdownWithContext` function in `app_test.go`, the `clientDone` channel is used to synchronize the client's request completion before proceeding, eliminating the need for additional `time.Sleep` calls.
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3051
File: middleware/session/session.go:215-216
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Parallel tests for `Session.Save` already exist in the `middleware/session/session_test.go` file, specifically in the `Test_Session_Save` and `Test_Session_Save_Expiration` functions.
Applied to files:
middleware/adaptor/adaptor_test.go
π Learning: 2024-10-12T10:01:44.206Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:190-191
Timestamp: 2024-10-12T10:01:44.206Z
Learning: When testing session `IdleTimeout` expiration, it's acceptable to use `time.Sleep` to simulate the passage of time in tests.
Applied to files:
middleware/adaptor/adaptor_test.go
𧬠Code graph analysis (1)
middleware/adaptor/adaptor_test.go (1)
middleware/adaptor/adaptor.go (2)
HTTPHandlerWithContext(65-75)LocalContextFromHTTPRequest(78-81)
πͺ GitHub Actions: golangci-lint
middleware/adaptor/adaptor_test.go
[error] 1191-1191: SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
πͺ GitHub Check: lint
middleware/adaptor/adaptor_test.go
[failure] 1191-1191:
SA1029: should not use built-in type string as key for value; define your own type to avoid collisions (staticcheck)
β° 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). (2)
- GitHub Check: Compare
- GitHub Check: repeated
π Additional comments (1)
middleware/adaptor/adaptor_test.go (1)
1157-1157: LGTM: Proper benchmark timer reset.Adding
b.ResetTimer()after setup and before the benchmark loop is a best practice that ensures initialization overhead doesn't skew the benchmark results.
|
@TheAspectDev can you add something in the markdown documentation for this new feature |
β¦uest and HTTPHandlerWithContext
There was a problem hiding this comment.
Actionable comments posted: 1
Fix all issues with AI Agents π€
In @docs/middleware/adaptor.md:
- Around line 207-246: The example code block (functions main and handleRequest,
and their middleware/usage of adaptor.HTTPHandlerWithContext) contains hard tab
characters for indentation; replace all hard tabs with spaces (match existing
file style, e.g., 4 spaces per indent) throughout the snippet so markdownlint
MD010 passes, then run make markdown to verify/lint the docs.
π§Ή Nitpick comments (1)
docs/middleware/adaptor.md (1)
35-35: Minor: Improve description consistency in HTTPHandlerWithContext entry.Line 35's description "http.Handler -> fiber.Handler (with context.Context)" uses shorthand notation, while comparable entries follow the pattern "Converts X to Y". For consistency, consider rewording to: "Converts
http.Handlertofiber.Handlerwith Fiber user context propagation" or similar.Also applies to: 43-43
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (6)
π 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: 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: 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.
π 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: 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
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~35-~35: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | |HTTPHandlerWithContext|HTTPHandlerWithContext(h http.Handler) fiber.Handler|http.Handler -> fiber.Handler (with co...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~35-~35: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler|http.Handler -> fiber.Handler (with context.Context)| | HTTPHandlerF...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~37-~37: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~38-~38: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~38-~38: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
πͺ markdownlint-cli2 (0.18.1)
docs/middleware/adaptor.md
207-207: Hard tabs
Column: 1
(MD010, no-hard-tabs)
208-208: Hard tabs
Column: 1
(MD010, no-hard-tabs)
209-209: Hard tabs
Column: 1
(MD010, no-hard-tabs)
211-211: Hard tabs
Column: 1
(MD010, no-hard-tabs)
212-212: Hard tabs
Column: 1
(MD010, no-hard-tabs)
219-219: Hard tabs
Column: 1
(MD010, no-hard-tabs)
221-221: Hard tabs
Column: 1
(MD010, no-hard-tabs)
222-222: Hard tabs
Column: 1
(MD010, no-hard-tabs)
223-223: Hard tabs
Column: 1
(MD010, no-hard-tabs)
225-225: Hard tabs
Column: 1
(MD010, no-hard-tabs)
227-227: Hard tabs
Column: 1
(MD010, no-hard-tabs)
228-228: Hard tabs
Column: 1
(MD010, no-hard-tabs)
229-229: Hard tabs
Column: 1
(MD010, no-hard-tabs)
230-230: Hard tabs
Column: 1
(MD010, no-hard-tabs)
232-232: Hard tabs
Column: 1
(MD010, no-hard-tabs)
233-233: Hard tabs
Column: 1
(MD010, no-hard-tabs)
235-235: Hard tabs
Column: 1
(MD010, no-hard-tabs)
239-239: Hard tabs
Column: 1
(MD010, no-hard-tabs)
240-240: Hard tabs
Column: 1
(MD010, no-hard-tabs)
241-241: Hard tabs
Column: 1
(MD010, no-hard-tabs)
242-242: Hard tabs
Column: 1
(MD010, no-hard-tabs)
243-243: Hard tabs
Column: 1
(MD010, no-hard-tabs)
245-245: Hard tabs
Column: 1
(MD010, no-hard-tabs)
246-246: Hard tabs
Column: 1
(MD010, no-hard-tabs)
π Additional comments (1)
docs/middleware/adaptor.md (1)
200-249: LGTM: Example clearly demonstrates context propagation feature.Section 6 effectively demonstrates the intended use caseβpropagating Fiber user context to net/http handlers via
HTTPHandlerWithContextandLocalContextFromHTTPRequest. The example is realistic, well-structured, and directly addresses the issue #2711 objective. The error handling (nil check, ok flag) is appropriate, and the type-safe pattern with a customctxKeytype is idiomatic.Once hard tabs are replaced with spaces, this example will provide clear guidance to users on integrating Fiber context with adapted net/http handlers.
Run
make markdownafter fixing hard tabs to ensure all linting passes.
There was a problem hiding this comment.
Actionable comments posted: 2
Fix all issues with AI Agents π€
In @docs/middleware/adaptor.md:
- Around line 246-291: Replace all hard tab characters with four space
characters in the Go code block that defines package main, the main() function,
the Fiber middleware (app.Use), the route registration (app.Get with
adaptor.HTTPHandlerWithContext), and the handleRequest function so indentation
uses spaces consistently; after replacing tabs run make markdown to lint and
ensure MD010 violations are resolved.
- Around line 241-243: Add a blank line before the "### 6. Passing Fiber user
context into `net/http`" heading to satisfy MD022, then renumber the headings to
avoid duplicate "6": change the heading text "### 6. Passing Fiber user context
into `net/http`" to "### 7. Passing Fiber user context into `net/http`" and
update the subsequent "### 7" heading (the one currently after line 292) to "###
8" so section numbering remains sequential.
π§Ή Nitpick comments (1)
docs/middleware/adaptor.md (1)
42-42: Minor: Align API table description style.The description for
HTTPHandlerWithContextuses a slightly different format ("β" shorthand without "Converts") compared to neighboring entries. For consistency, consider:HTTPHandlerWithContext(h http.Handler) fiber.Handler| Convertshttp.Handlertofiber.Handlerwith context propagation.
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (7)
π 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: 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: 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.
π 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-10-08T19:06:06.583Z
Learnt from: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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: 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
πͺ GitHub Actions: markdownlint
docs/middleware/adaptor.md
[error] 243-243: markdownlint: MD022/blanks-around-headings Headings should be surrounded by blank lines [Context: "### 6. Passing Fiber user context into net/http"]
πͺ GitHub Check: markdownlint
docs/middleware/adaptor.md
[failure] 266-266: Hard tabs
docs/middleware/adaptor.md:266:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 265-265: Hard tabs
docs/middleware/adaptor.md:265:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 264-264: Hard tabs
docs/middleware/adaptor.md:264:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 262-262: Hard tabs
docs/middleware/adaptor.md:262:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 255-255: Hard tabs
docs/middleware/adaptor.md:255:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 254-254: Hard tabs
docs/middleware/adaptor.md:254:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 252-252: Hard tabs
docs/middleware/adaptor.md:252:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 251-251: Hard tabs
docs/middleware/adaptor.md:251:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 250-250: Hard tabs
docs/middleware/adaptor.md:250:1 MD010/no-hard-tabs Hard tabs [Column: 1] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md010.md
[failure] 243-243: Headings should be surrounded by blank lines
docs/middleware/adaptor.md:243 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "### 6. Passing Fiber user context into net/http"] https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/md022.md
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | |HTTPHandlerWithContext|HTTPHandlerWithContext(h http.Handler) fiber.Handler|http.Handler -> fiber.Handler (with co...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler|http.Handler -> fiber.Handler (with context.Context)| | HTTPHandlerF...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
πͺ markdownlint-cli2 (0.18.1)
docs/middleware/adaptor.md
250-250: Hard tabs
Column: 1
(MD010, no-hard-tabs)
251-251: Hard tabs
Column: 1
(MD010, no-hard-tabs)
252-252: Hard tabs
Column: 1
(MD010, no-hard-tabs)
254-254: Hard tabs
Column: 1
(MD010, no-hard-tabs)
255-255: Hard tabs
Column: 1
(MD010, no-hard-tabs)
262-262: Hard tabs
Column: 1
(MD010, no-hard-tabs)
264-264: Hard tabs
Column: 1
(MD010, no-hard-tabs)
265-265: Hard tabs
Column: 1
(MD010, no-hard-tabs)
266-266: Hard tabs
Column: 1
(MD010, no-hard-tabs)
268-268: Hard tabs
Column: 1
(MD010, no-hard-tabs)
270-270: Hard tabs
Column: 1
(MD010, no-hard-tabs)
271-271: Hard tabs
Column: 1
(MD010, no-hard-tabs)
272-272: Hard tabs
Column: 1
(MD010, no-hard-tabs)
273-273: Hard tabs
Column: 1
(MD010, no-hard-tabs)
275-275: Hard tabs
Column: 1
(MD010, no-hard-tabs)
276-276: Hard tabs
Column: 1
(MD010, no-hard-tabs)
278-278: Hard tabs
Column: 1
(MD010, no-hard-tabs)
282-282: Hard tabs
Column: 1
(MD010, no-hard-tabs)
283-283: Hard tabs
Column: 1
(MD010, no-hard-tabs)
284-284: Hard tabs
Column: 1
(MD010, no-hard-tabs)
285-285: Hard tabs
Column: 1
(MD010, no-hard-tabs)
286-286: Hard tabs
Column: 1
(MD010, no-hard-tabs)
288-288: Hard tabs
Column: 1
(MD010, no-hard-tabs)
289-289: Hard tabs
Column: 1
(MD010, no-hard-tabs)
β° 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). (5)
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: unit (1.25.x, macos-latest)
- GitHub Check: repeated
- GitHub Check: Compare
- GitHub Check: lint
There was a problem hiding this comment.
Actionable comments posted: 2
Fix all issues with AI Agents π€
In @docs/middleware/adaptor.md:
- Line 49: Replace the malformed double-backtick inline code formatting in the
API reference table row for LocalContextFromHTTPRequest: change occurrences like
``LocalContextFromHTTPRequest``, ``r *http.Request``, ``context.Context``, and
``http.Request`` to single-backtick inline code (e.g.,
`LocalContextFromHTTPRequest(r *http.Request) (context.Context, bool)`) to match
the rest of the docs and ensure consistent rendering of the signature and types.
- Line 42: Update the table entry for the symbol HTTPHandlerWithContext so its
description matches the other rows: replace the shorthand "`http.Handler ->
fiber.Handler (with context.Context)`" with a full phrase like "Converts
`http.Handler` to `fiber.Handler` (propagating `context.Context`)" to ensure
consistency and clarity in the API reference.
β»οΈ Duplicate comments (1)
docs/middleware/adaptor.md (1)
241-246: Fix heading formatting, section numbering, and hard tabs (duplicate flagging).This section has three issues previously flagged that remain unresolved:
- Missing blank line before heading (MD022): Add a blank line between line 241 (code block close) and line 243 (heading).
- Duplicate section numbering: Line 243 is numbered "### 6" but line 202 is also "### 6". Change line 243 to "### 7" and update the subsequent "### 7" (now line 294) to "### 8".
- Hard tabs in code block (MD010): Lines 247β292 contain hard tabs for indentation. Replace with spaces (4 spaces per indent level).
Per coding guidelines, after fixing indentation and numbering, run
make markdownto lint and verify compliance.π Proposed fix outline
- Insert blank line after line 241 (before the heading at line 243)
- Change line 243 from
### 6. Passing...to### 7. Passing...- Change line 294 from
### 7. Copying...to### 8. Copying...- In the code block (lines 247β292), replace all leading hard tabs with 4 spaces per indent level
- Run
make markdownto verify
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (12)
π 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: 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: 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.
π 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: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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-12-07T15:07:23.885Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-07T15:07:23.885Z
Learning: Applies to **/*.go : Prefer `github.com/gofiber/utils/v2` helpers (for example, `utils.Trim`) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
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
π 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-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: sigmundxia
Repo: gofiber/fiber PR: 3151
File: middleware/adaptor/adaptor_test.go:226-230
Timestamp: 2024-10-08T19:06:06.583Z
Learning: In Fiber, the `c.Set` method does not return an error.
Applied to files:
docs/middleware/adaptor.md
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | |HTTPHandlerWithContext|HTTPHandlerWithContext(h http.Handler) fiber.Handler|http.Handler -> fiber.Handler (with co...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...r) fiber.Handler|http.Handler -> fiber.Handler (with context.Context)| | HTTPHandlerF...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
β° 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). (4)
- GitHub Check: Compare
- GitHub Check: repeated
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: lint
π Additional comments (1)
docs/middleware/adaptor.md (1)
247-292: Code example is clear and demonstrates the feature well.The new usage example correctly shows:
- Fiber middleware setting a request-scoped context with
SetUserContext()- Wrapping a
net/httphandler withHTTPHandlerWithContextto propagate context- The handler retrieving context via
LocalContextFromHTTPRequest()and accessing valuesOnce the hard tabs and heading issues (flagged above) are resolved, this example will be ready. The logic and flow are sound.
After fixing indentation and section numbering, verify the example renders correctly and that the function signatures match the implementation in
middleware/adaptor/adaptor.go.
There was a problem hiding this comment.
Actionable comments posted: 0
β»οΈ Duplicate comments (1)
docs/middleware/adaptor.md (1)
241-294: Fix section numbering and add missing blank line before heading.This issue was flagged in prior reviews but remains unresolved. There are two problems:
- Duplicate section number: Both line 202 ("### 6. Converting...") and line 243 ("### 6. Passing...") are numbered "6". Section 243 should be "### 7".
- Duplicate section 7: Line 294 ("### 7. Copying...") should be "### 8" after renumbering.
- Missing blank line: Line 243 is missing a blank line before it (MD022 violation). The heading must be preceded by a blank line.
π Proposed fix for section numbering and formatting
return c.SendString("Converted Request URL: " + httpReq.URL.String()) }
-### 6. Passing Fiber user context into
net/http
+### 7. Passing Fiber user context intonet/httpThen update line 294: ```diff -### 7. Copying context values onto `fasthttp.RequestCtx` (`CopyContextToFiberContext`) +### 8. Copying context values onto `fasthttp.RequestCtx` (`CopyContextToFiberContext`)After applying these fixes, run
make markdownto verify all linting issues are resolved.
π§Ή Nitpick comments (2)
docs/middleware/adaptor.md (2)
49-49: Fix inline code formatting in API reference table.The left column for
LocalContextFromHTTPRequestshould use single backticks to match other API reference entries. The current formatting may use double backticks (e.g.,`LocalContextFromHTTPRequest`) which renders inconsistently.π Proposed fix for consistency
-|`LocalContextFromHTTPRequest`|`LocalContextFromHTTPRequest(r *http.Request) (context.Context, bool)`|Extracts the propagated `context.Context` from an adapted `http.Request`| +|`LocalContextFromHTTPRequest`|`LocalContextFromHTTPRequest(r *http.Request) (context.Context, bool)`|Extracts the propagated `context.Context` from an adapted `http.Request`|Verify the source uses single backticks throughout the API reference table for consistent rendering.
344-351: Consider highlighting context propagation in the summary.The Summary section provides a good overview but doesn't mention the new context propagation capability (HTTPHandlerWithContext and LocalContextFromHTTPRequest). Adding a brief bullet point about propagating Fiber's context into
net/httphandlers would help users discover this feature.π Proposed enhancement
## Summary The `adaptor` package lets Fiber and `net/http` interoperate so you can: - Convert handlers and middleware in both directions - Run Fiber apps inside `net/http` - Convert `fiber.Ctx` to `http.Request` +- Propagate Fiber's user context into adapted `net/http` handlers This makes it straightforward to integrate Fiber with existing Go projects or migrate between frameworks.
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (7)
π 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: 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: 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.
π 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: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | |HTTPHandlerWithContext|HTTPHandlerWithContext(h http.Handler) fiber.Handler|Converts http.Handler to `fiber.Hand...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...h http.Handler) fiber.Handler|Converts http.Handlertofiber.Handler`, propagating Fiber'...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ber.Handler|Converts http.Handlertofiber.Handler`, propagating Fiber's local context| | ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
β° 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). (5)
- GitHub Check: lint
- GitHub Check: Compare
- GitHub Check: unit (1.25.x, macos-latest)
- GitHub Check: repeated
- GitHub Check: unit (1.25.x, windows-latest)
π Additional comments (1)
docs/middleware/adaptor.md (1)
247-292: Code example is clear and complete.The new usage example effectively demonstrates how to propagate Fiber's user context into
net/httphandlers usingHTTPHandlerWithContextandLocalContextFromHTTPRequest. The indentation uses spaces (tabs have been properly replaced), and the flow is realistic and educational.Note: Once the section numbering issue (flagged above at lines 241β294) is resolved, this example will be properly positioned as section 7.
There was a problem hiding this comment.
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 (1)
docs/middleware/adaptor.md (1)
1-351: Fix markdown line-length violations before merging.The file has 25 MD013 line-length violations (expected max 80 characters). Lines 7, 18β20, 33, 39β50, 58, 204, 207, 209, 245, 265, 318, 325, and 353 exceed this limit. Run
make markdownto verify all linting passes after corrections.
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (9)
π 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: 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: 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.
π 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-10-08T19:06:06.583Z
Learnt from: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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: 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/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: 2025-12-07T15:07:23.885Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-07T15:07:23.885Z
Learning: Applies to **/*.go : Prefer `github.com/gofiber/utils/v2` helpers (for example, `utils.Trim`) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Applied to files:
docs/middleware/adaptor.md
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | |HTTPHandlerWithContext|HTTPHandlerWithContext(h http.Handler) fiber.Handler|Converts http.Handler to `fiber.Hand...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...h http.Handler) fiber.Handler|Converts http.Handlertofiber.Handler`, propagating Fiber'...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ber.Handler|Converts http.Handlertofiber.Handler`, propagating Fiber's local context| | ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | FiberHandler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | | `FiberHandle...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
β° 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). (5)
- GitHub Check: lint
- GitHub Check: Compare
- GitHub Check: unit (1.25.x, macos-latest)
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: repeated
π Additional comments (4)
docs/middleware/adaptor.md (4)
42-49: API reference entries are clear and properly formatted.The two new API entries correctly document
HTTPHandlerWithContextandLocalContextFromHTTPRequest. Both follow the table format of existing entries and accurately describe their purpose. Inline code formatting uses single backticks consistently.
243-294: Section structure and heading formatting are correct.The new section 7 ("Passing Fiber user context into
net/http") is properly blank-lined before its heading (satisfying MD022). Section numbering is sequential (section 6 ends at line 241 β section 7 at 243 β section 8 at 294), with no duplicates.
247-292: Code example clearly demonstrates the feature per PR objectives.The example correctly shows:
- Middleware setting a request-scoped context via
c.SetUserContext()- Route using
adaptor.HTTPHandlerWithContext()to adapt the net/http handler- Handler retrieving the propagated context via
adaptor.LocalContextFromHTTPRequest(r)- Extraction of values from the propagated context
This aligns with the PR's goal to expose Fiber's local/UserContext to adapted net/http handlers through the public
LocalContextKey.
351-351: Summary correctly reflects the new feature.The addition "Propagate Fiber's user context into adapted
net/httphandlers" appropriately documents the new capability introduced by this PR.
|
there's something seriously wrong with my table formatting |
|
β fiber git:(fix/2711-local-context) make markdown @ReneWerner87 would you mind guiding me through the problem? |
There was a problem hiding this comment.
Actionable comments posted: 2
π€ Fix all issues with AI Agents
In @docs/middleware/adaptor.md:
- Around line 243-294: The example uses the deprecated Fiber v3 API call
c.SetUserContext(ctx); replace that call with the correct Fiber v3 method
c.SetContext(ctx) in the middleware function that sets the request-scoped
context (the anonymous app.Use handler) so Fiber stores the request context
correctly before calling c.Next().
- Around line 243-292: The example uses the old Fiber v3 API call
c.SetUserContext(ctx); replace that call with c.SetContext(ctx) where the Fiber
middleware sets the request-scoped context so the net/http handler can retrieve
it via adaptor.LocalContextFromHTTPRequest; update the example to call
c.SetContext(ctx) after creating ctx := context.WithValue(...), then run
documentation linting (make markdown) before merging.
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (9)
π 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: 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: 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.
π 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-10-08T19:06:06.583Z
Learnt from: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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: 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/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: 2025-12-07T15:07:23.885Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-07T15:07:23.885Z
Learning: Applies to **/*.go : Prefer `github.com/gofiber/utils/v2` helpers (for example, `utils.Trim`) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Applied to files:
docs/middleware/adaptor.md
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPHandlerWithContext | HTTPHandlerWithContext(h http.Handler) fiber.Handler | Converts `htt...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...dler | Convertshttp.Handlertofiber.Handler`, propagating Fiber'...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler, propagating Fiber's local context | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | `FiberHand...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | FiberHandler | FiberHandler(h fiber.Handler) http.Handler | Con...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
β° 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). (5)
- GitHub Check: lint
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: unit (1.25.x, macos-latest)
- GitHub Check: repeated
- GitHub Check: Compare
π Additional comments (1)
docs/middleware/adaptor.md (1)
39-50: API reference table is consistent and complete.The updated table correctly lists
HTTPHandlerWithContextandLocalContextFromHTTPRequestwith consistent formatting. Descriptions use proper inline code formatting (single backticks) and the signatures are clearly presented.Minor style note: Multiple descriptions begin with "Converts" (lines 41, 42, 43, 44, 45, 46, 47, 48), which LanguageTool flags as repetitive. For a reference table, this trade-off between clarity and variety is acceptable, though you could consider alternating verbs (e.g., "Converts" vs. "Wraps" vs. "Extracts") if stylistic consistency is desired across the documentation set.
There was a problem hiding this comment.
Actionable comments posted: 0
π§Ή Nitpick comments (1)
docs/middleware/adaptor.md (1)
39-50: Consider varying opening verbs in API reference descriptions for better readability.Lines 41β47 all begin with "Converts," creating repetitive phrasing. While clear, varied verbs (e.g., "Wraps," "Adapts," "Registers") would improve readability without losing clarity.
π Example variation
-| `HTTPHandler` | `HTTPHandler(h http.Handler) fiber.Handler` | Converts `http.Handler` to `fiber.Handler` | -| `HTTPHandlerWithContext` | `HTTPHandlerWithContext(h http.Handler) fiber.Handler` | Converts `http.Handler` to `fiber.Handler`, propagating Fiber's local context | +| `HTTPHandler` | `HTTPHandler(h http.Handler) fiber.Handler` | Adapts `http.Handler` as a `fiber.Handler` | +| `HTTPHandlerWithContext` | `HTTPHandlerWithContext(h http.Handler) fiber.Handler` | Adapts `http.Handler` as a `fiber.Handler`, propagating Fiber's local context |(Apply similar variations to other rows as appropriate)
π Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
π 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
docsfolder if necessary when modifying code
Files:
docs/middleware/adaptor.md
**/*.md
π CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/middleware/adaptor.md
π§ Learnings (10)
π 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: 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: 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.
π 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-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: 2024-10-08T19:06:06.583Z
Learnt from: hcancelik
Repo: gofiber/fiber PR: 3036
File: docs/middleware/cache.md:103-103
Timestamp: 2024-10-08T19:06:06.583Z
Learning: There are no hard tabs in the lines 100 to 105 of the `docs/middleware/cache.md` file. Future comments about formatting should accurately reflect the actual content.
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: 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: 2025-12-07T15:07:23.885Z
Learnt from: CR
Repo: gofiber/fiber PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-07T15:07:23.885Z
Learning: Applies to **/*.go : Prefer `github.com/gofiber/utils/v2` helpers (for example, `utils.Trim`) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Applied to files:
docs/middleware/adaptor.md
πͺ LanguageTool
docs/middleware/adaptor.md
[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~41-~41: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | | HTTPHandlerWithContext | HTTPHandlerWithContext(h http.Handler) fiber.Handler | Converts `htt...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...dler | Convertshttp.Handlertofiber.Handler`, propagating Fiber'...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~42-~42: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts http.Handler to fiber.Handler, propagating Fiber's local context | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~44-~44: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...| Converts http.Handler middleware to fiber.Handler middleware | | `FiberHand...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler ...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~45-~45: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... | Converts fiber.Handler to http.Handler | |...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
β° 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). (5)
- GitHub Check: Compare
- GitHub Check: lint
- GitHub Check: repeated
- GitHub Check: unit (1.25.x, windows-latest)
- GitHub Check: unit (1.25.x, macos-latest)
π Additional comments (1)
docs/middleware/adaptor.md (1)
243-292: Excellent example demonstrating context propagation across the Fiber β net/http boundary.The code correctly uses Fiber v3 API (
c.SetContext()on line 272), demonstrates the newHTTPHandlerWithContextandLocalContextFromHTTPRequesthelpers, and includes clear comments explaining the flow. The section numbering is correct (section 7 followed by section 8).
Description
Local context ( known as
UserContext) was inaccessible while usingnet/httphandlers ( with adaptors ).This is fixed by appending the local context inside a key called
LocalContextKeyin Request context ( which is accessible inside net/http handlers )βοΈI would need some help from the maintainers to provide a readable example/doc
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.
Fixes #2711
Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements: