Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ”₯ feat: Add local context support to adaptor middleware#3975

Merged
ReneWerner87 merged 24 commits intogofiber:mainfrom
TheAspectDev:fix/2711-local-context
Jan 6, 2026
Merged

πŸ”₯ feat: Add local context support to adaptor middleware#3975
ReneWerner87 merged 24 commits intogofiber:mainfrom
TheAspectDev:fix/2711-local-context

Conversation

@TheAspectDev
Copy link
Contributor

@TheAspectDev TheAspectDev commented Dec 29, 2025

Description

Local context ( known as UserContext ) was inaccessible while using net/http handlers ( with adaptors ).
This is fixed by appending the local context inside a key called LocalContextKey in 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.

  • Benchmarks: Describe any performance benchmarks and improvements related to the changes.
goos: darwin
goarch: arm64
pkg: github.com/gofiber/fiber/v3/middleware/adaptor
cpu: Apple M4
             β”‚ bench_old.txt β”‚         bench_new.txt         β”‚
             β”‚    sec/op     β”‚   sec/op     vs base          β”‚
_HTTPHandler    897.4n Β± 22%   931.2n Β± 9%  ~ (p=0.853 n=10)

             β”‚ bench_old.txt β”‚          bench_new.txt           β”‚
             β”‚     B/op      β”‚     B/op      vs base            β”‚
_HTTPHandler    1.773Ki Β± 0%   1.773Ki Β± 0%  ~ (p=1.000 n=10) ΒΉ
ΒΉ all samples are equal

             β”‚ bench_old.txt β”‚         bench_new.txt          β”‚
             β”‚   allocs/op   β”‚ allocs/op   vs base            β”‚
_HTTPHandler      18.00 Β± 0%   18.00 Β± 0%  ~ (p=1.000 n=10) ΒΉ
ΒΉ all samples are equal
  • Examples: Provide examples demonstrating the new features or changes in action.
type ctxKey string
const usernameKey ctxKey = "username"

app.Use(func(c fiber.Ctx) error {
	ctx := context.WithValue(c, "username", "fibername")
	c.SetContext(ctx)
	return c.Next()
})

app.Get("/hello", adaptor.HTTPHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/plain; charset=utf-8")

	ctx, ok := r.Context().Value(adaptor.LocalContextKey).(context.Context)
	if !ok {
		http.Error(w, "context not found", http.StatusInternalServerError)
		return
	}

	name, ok := ctx.Value(usernameKey).(string)
	if !ok {
		http.Error(w, "username missing", http.StatusInternalServerError)
		return
	}

	w.WriteHeader(http.StatusOK)
	w.Write([]byte(name)) // should write "fibername"
})))

Fixes #2711

Type of change

Please delete options that are not relevant.

  • Enhancement (improvement to existing features and functionality)

Checklist

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

  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

Walkthrough

Stores 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

Cohort / File(s) Summary
Adaptor core
middleware/adaptor/adaptor.go
Added unexported localContextKey, imported context, implemented HTTPHandlerWithContext(h http.Handler) fiber.Handler to store c.UserContext() into the fasthttp request context before calling the adapted handler, and added LocalContextFromHTTPRequest(r *http.Request) (context.Context, bool) to extract it.
Tests: local context propagation
middleware/adaptor/adaptor_test.go
Added Test_HTTPHandlerWithContext_local_context verifying propagation, added Benchmark_HTTPHandlerWithContext, and inserted b.ResetTimer() in an existing benchmark.
Documentation / Examples
docs/middleware/adaptor.md
Documented HTTPHandlerWithContext and LocalContextFromHTTPRequest, replaced prior CopyContext narrative with β€œPassing Fiber user context into net/http” and added a usage example showing propagation.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

πŸ“’ Documentation

Suggested reviewers

  • gaby
  • sixcolors
  • efectn

Poem

🐰 I tuck a context key inside,

A tiny hop where data hides,
From Fiber's fields into net/http flow,
I carry traces where handlers go,
Hop quick β€” the request now glides.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (4 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly summarizes the main change: adding local context support to the adaptor middleware to make Fiber's UserContext accessible to net/http handlers.
Description check βœ… Passed The description covers the problem, solution, includes benchmarks and examples, and most checklist items are marked complete; however, Documentation Update and Changelog/What's New sections are not explicitly addressed.
Linked Issues check βœ… Passed The PR fully addresses issue #2711 by implementing local context propagation through HTTPHandlerWithContext and LocalContextFromHTTPRequest, making Fiber's UserContext accessible to adapted net/http handlers.
Out of Scope Changes check βœ… Passed All changes are directly related to issue #2711: code changes add context propagation support, tests validate the feature, and documentation updates explain the new API and usage patterns.

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

❀️ Share

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Context Propagation: The pull request fixes an issue where the local Fiber context (UserContext) was not accessible within net/http handlers when using the adaptor middleware.
  • Solution Implementation: The local Fiber context is now appended to the http.Request context under the key 'local_context', allowing net/http handlers to retrieve and utilize it.
  • Interoperability: This enhancement improves the interoperability between Fiber's context management and standard Go net/http handlers, resolving issue πŸ› [Bug]: UserContext no more accessible when adapting http.Handler to fiber.HandlerΒ #2711.

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

Using Gemini Code Assist

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

Invoking Gemini

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

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

Customization

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

Limitations & Feedback

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

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

Footnotes

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

@ReneWerner87 ReneWerner87 added this to v3 Dec 29, 2025
@ReneWerner87 ReneWerner87 added this to the v3 milestone Dec 29, 2025
@codecov
Copy link

codecov bot commented Dec 29, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 91.07%. Comparing base (5474336) to head (571d138).
⚠️ Report is 4 commits behind head on main.

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     
Flag Coverage Ξ”
unittests 91.07% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This pull request 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (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:

  1. Exporting the constant with a clearer name (e.g., LocalContextKey)
  2. 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 of adaptor.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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 789c56f and 6a9fb33.

πŸ“’ Files selected for processing (2)
  • middleware/adaptor/adaptor.go
  • 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/v2 helpers (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
  • middleware/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.go
  • middleware/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.go
  • 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_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_context at 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 via c.SetUserContext() from adapted handlers. Please confirm that:

  1. The fasthttp adaptor properly propagates user values set via SetUserValue to the Go context.Context returned by r.Context() in the net/http handler
  2. 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
middleware/adaptor/adaptor_test.go (1)

291-293: Replace t.Fatal with t.Errorf or HTTP error responses in handler.

According to the Fiber codebase linter rules, t.Fatal and similar assertions from testing packages are not allowed within HTTP handlers (including net/http-style handlers). Use t.Errorf with 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 c under LocalContextKey. 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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 6a9fb33 and 3d68610.

πŸ“’ Files selected for processing (2)
  • middleware/adaptor/adaptor.go
  • middleware/adaptor/adaptor_test.go
🧰 Additional context used
πŸ““ Path-based instructions (2)
**/*.go

πŸ“„ CodeRabbit inference engine (AGENTS.md)

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

Files:

  • middleware/adaptor/adaptor.go
  • middleware/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.go
  • 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.go
  • 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
  • middleware/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.go
  • 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.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 localCtxKey for the context key is the correct approach to avoid collisions between packages, as recommended in the Go context documentation. Exporting LocalContextKey allows users to retrieve the stored context from adapted handlers.

@TheAspectDev
Copy link
Contributor Author

Hey, is this benchmark related to the pr?
It seems related to NewError

@gaby
Copy link
Member

gaby commented Dec 30, 2025

Hey, is this benchmark related to the pr? It seems related to NewError

Yeah, it's unrelated

@gaby gaby changed the title 🩹 fix: append local context to the request context on adaptor.go/HTTPHandler πŸ”₯ feat: Add local context support to adaptor middleware Dec 30, 2025
@gaby gaby requested a review from Copilot December 30, 2025 00:06
@gaby
Copy link
Member

gaby commented Dec 30, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

πŸ’‘ 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".

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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 with http.Error instead of t.Fatal inside the handler.

Optional: Consider removing t.Logf from handler

While the test is correct, Line 300 uses t.Logf inside the HTTP handler. Though app.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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between d9820b4 and 16c7b21.

πŸ“’ 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/v2 helpers (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
Copy link
Contributor Author

@ReneWerner87

@ReneWerner87
Copy link
Member

@TheAspectDev can you add something in the markdown documentation for this new feature
otherwise no one will know it and also not use it

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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.Handler to fiber.Handler with Fiber user context propagation" or similar.

Also applies to: 43-43

πŸ“œ Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 94662d0 and 16a6844.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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 HTTPHandlerWithContext and LocalContextFromHTTPRequest. 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 custom ctxKey type 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 markdown after fixing hard tabs to ensure all linting passes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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 HTTPHandlerWithContext uses a slightly different format ("β†’" shorthand without "Converts") compared to neighboring entries. For consistency, consider: HTTPHandlerWithContext(h http.Handler) fiber.Handler | Converts http.Handler to fiber.Handler with context propagation.

πŸ“œ Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 16a6844 and 29ef67f.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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:

  1. Missing blank line before heading (MD022): Add a blank line between line 241 (code block close) and line 243 (heading).
  2. 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".
  3. 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 markdown to lint and verify compliance.

πŸ”Ž Proposed fix outline
  1. Insert blank line after line 241 (before the heading at line 243)
  2. Change line 243 from ### 6. Passing... to ### 7. Passing...
  3. Change line 294 from ### 7. Copying... to ### 8. Copying...
  4. In the code block (lines 247–292), replace all leading hard tabs with 4 spaces per indent level
  5. Run make markdown to verify
πŸ“œ Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 29ef67f and aac5e02.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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/http handler with HTTPHandlerWithContext to propagate context
  • The handler retrieving context via LocalContextFromHTTPRequest() and accessing values

Once 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.

@TheAspectDev
Copy link
Contributor Author

@ReneWerner87

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ 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:

  1. Duplicate section number: Both line 202 ("### 6. Converting...") and line 243 ("### 6. Passing...") are numbered "6". Section 243 should be "### 7".
  2. Duplicate section 7: Line 294 ("### 7. Copying...") should be "### 8" after renumbering.
  3. 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 into net/http


Then 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 markdown to 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 LocalContextFromHTTPRequest should 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/http handlers 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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 96e981b and 32af645.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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/http handlers using HTTPHandlerWithContext and LocalContextFromHTTPRequest. 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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 markdown to verify all linting passes after corrections.

πŸ“œ Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 32af645 and 2f30ef4.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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 HTTPHandlerWithContext and LocalContextFromHTTPRequest. 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/http handlers" appropriately documents the new capability introduced by this PR.

@TheAspectDev
Copy link
Contributor Author

there's something seriously wrong with my table formatting

@TheAspectDev
Copy link
Contributor Author

➜ fiber git:(fix/2711-local-context) make markdown
markdownlint-cli2 "**/.md" "#vendor"
markdownlint-cli2 v0.20.0 (markdownlint v0.40.0)
Finding: **/
.md !vendor
Linting: 74 file(s)
Summary: 0 error(s)
➜ fiber git:(fix/2711-local-context)

@ReneWerner87 would you mind guiding me through the problem?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 2f30ef4 and 55c7936.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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 HTTPHandlerWithContext and LocalContextFromHTTPRequest with 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 55c7936 and 571d138.

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

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

Files:

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

πŸ“„ CodeRabbit inference engine (.github/copilot-instructions.md)

Run make markdown to lint all Markdown files when modifying code

Files:

  • docs/middleware/adaptor.md
🧠 Learnings (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 new HTTPHandlerWithContext and LocalContextFromHTTPRequest helpers, and includes clear comments explaining the flow. The section numbering is correct (section 7 followed by section 8).

@ReneWerner87 ReneWerner87 merged commit 1430405 into gofiber:main Jan 6, 2026
15 of 16 checks passed
@github-project-automation github-project-automation bot moved this to Done in v3 Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

πŸ› [Bug]: UserContext no more accessible when adapting http.Handler to fiber.Handler

4 participants