🔥 feat: Implement OverrideParam override behavior for DefaultCtx#3962
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughA new public method Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @TheAspectDev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new UpdateParam method to the context, allowing for the modification of route parameters. The implementation is straightforward and includes comprehensive tests, benchmarks, and documentation. My main feedback is to improve the clarity and correctness of the new documentation for UpdateParam.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
docs/api/ctx.md (1)
506-508: Usefiber.Ctxas receiver type for consistency.The signature shows
*DefaultCtxas the receiver type, but for consistency with other method signatures in this documentation (e.g., lines 49, 608, 703), it should usefiber.Ctx.🔎 Suggested fix
-```go title="Signature" -func (c *DefaultCtx) UpdateParam(name, value string) -``` +```go title="Signature" +func (c fiber.Ctx) UpdateParam(name string, value string) +```ctx_test.go (1)
8006-8027: Consider a more focused benchmark for UpdateParam.The current benchmark measures the entire HTTP request/response cycle (
app.Test(req)includes routing, handler execution, response serialization, etc.), which adds significant overhead unrelated toUpdateParamitself.🔎 More focused benchmark measuring UpdateParam directly
func Benchmark_Ctx_UpdateParam(b *testing.B) { app := New(Config{ CBOREncoder: cbor.Marshal, CBORDecoder: cbor.Unmarshal, }) + c := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) + c.route = &Route{Params: []string{"name", "id"}} + c.values = [maxParams]string{"original", "123"} - app.Get("/user/:name/:id", func(c Ctx) error { - c.UpdateParam("name", "overridden") - return nil - }) - - req, err := http.NewRequest(http.MethodGet, "/user/original/123", http.NoBody) - require.NoError(b, err) - b.ReportAllocs() + b.ResetTimer() for b.Loop() { - resp, err := app.Test(req) - require.NoError(b, err) - require.NoError(b, resp.Body.Close()) + c.UpdateParam("name", "overridden") + c.values[0] = "original" // reset for next iteration } }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
ctx.goctx_interface_gen.goctx_test.godocs/api/ctx.md
🧰 Additional context used
📓 Path-based instructions (4)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
ctx_interface_gen.goctx.goctx_test.go
docs/**
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Review and update the contents of the
docsfolder if necessary when modifying code
Files:
docs/api/ctx.md
**/*.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/api/ctx.md
**/*_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:
ctx_test.go
🧠 Learnings (1)
📚 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/api/ctx.md
🧬 Code graph analysis (2)
ctx.go (1)
req.go (1)
Params(626-632)
ctx_test.go (3)
ctx_interface_gen.go (1)
Ctx(18-435)req.go (1)
Params(626-632)router.go (1)
Route(47-68)
🔇 Additional comments (2)
ctx.go (1)
386-399: LGTM! Well-implemented defensive programming.The implementation correctly handles the nil router case and safely updates route parameters. The bounds check
i < maxParamsis technically redundant sincec.valuesis already sized atmaxParams, but it's good defensive coding that adds negligible overhead.ctx_test.go (1)
7481-7524: LGTM! Comprehensive test coverage for UpdateParam.The test properly validates:
- Overriding existing route parameters (
name→overridden)- Ignoring updates to non-existing parameters (
existing)- Preserving unmodified parameters (
idremains123)- Safe handling when no route is set (nil router case)
The test structure follows best practices with
t.Parallel()calls and clear subtests.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
ctx_test.go (2)
7481-7524: Good coverage for UpdateParam; consider tightening assertions in the handler.The new test does exercise both overriding an existing param and the nil-router/no-op behavior, and
t.Parallel()is correctly used on the test and both subtests as per the test guidelines. As per coding guidelines, this is good.If you want to strengthen the behavioral guarantees a bit more:
- In the
"route_params"subtest handler, you already have access totvia closure. You could explicitly assert that a non-existent param remains empty and that the route param keys are unchanged, e.g.:app.Get("/user/:name/:id", func(c Ctx) error { c.UpdateParam("name", "overridden") c.UpdateParam("existing", "ignored") require.Equal(t, "overridden", c.Params("name")) require.Equal(t, "123", c.Params("id")) // or assert inside the test via JSON decode require.Empty(t, c.Params("existing")) require.Equal(t, []string{"name", "id"}, c.Route().Params) return c.JSON(map[string]any{ "name": c.Params("name"), "id": c.Params("id"), "all": c.Route().Params, }) })
- With those direct assertions in place, you can either keep or drop the
"all"field from the JSON, and therequire.NotContains(t, body, "existing")check becomes purely a safety net instead of the only signal for the ignored param.Not mandatory, but it would make the test more direct about the exact invariants you care about (existing key overridden, unknown key ignored, route metadata unchanged).
8005-8023: Benchmark is focused and consistent; you can drop the per-iteration reset if not needed.The benchmark setup mirrors existing patterns in this file (manual
DefaultCtx+ fixedRoute.Params/values) and gives a focused view onUpdateParamitself.If
UpdateParamdoesn’t depend on the previous value ofc.values[0](which it typically shouldn’t for a simple overwrite-by-name API), you can simplify and make the benchmark slightly cleaner by removing the reset from the hot loop:c := app.AcquireCtx(&fasthttp.RequestCtx{}).(*DefaultCtx) c.values = [maxParams]string{"original", "12345"} c.route = &Route{Params: []string{"name", "id"}} b.ReportAllocs() b.ResetTimer() for b.Loop() { c.UpdateParam("name", "changed") }That way you only measure the call itself, without the extra assignment cost on every iteration.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ctx_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:
ctx_test.go
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
ctx_test.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
📚 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:
ctx_test.go
🧬 Code graph analysis (1)
ctx_test.go (3)
ctx_interface_gen.go (1)
Ctx(18-435)req.go (1)
Params(626-632)router.go (1)
Route(47-68)
…ram, simplify benchmark behaviour
|
/gemini summary |
Summary of ChangesThis pull request introduces a new Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
|
|
/gemini review |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ctx_test.go (1)
8007-8023: Tighten the UpdateParam benchmark setup (optional)Two small nits you may want to address:
- The
CBOREncoder/CBORDecoderconfiguration onNewisn’t exercised byUpdateParam; you can simplify toapp := New()unless you intentionally want CBOR wired in here.- The forcible type assertion
.(*DefaultCtx)is consistent with other benchmarks but currently lacks the//nolint:errcheck,forcetypeassert // not neededcomment used elsewhere in this file; adding it would keep linters quiet and match the existing style.Neither affects correctness of the benchmark; they’re just minor cleanliness tweaks.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ctx_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:
ctx_test.go
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
ctx_test.go
🧠 Learnings (2)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 3161
File: app.go:923-932
Timestamp: 2024-11-15T07:56:21.623Z
Learning: In the Fiber framework, breaking changes are acceptable when moving from version 2 to version 3, including modifications to method signatures such as in the `Test` method in `app.go`.
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Applied to files:
ctx_test.go
🧬 Code graph analysis (1)
ctx_test.go (3)
ctx_interface_gen.go (1)
Ctx(18-435)req.go (1)
Params(626-632)router.go (1)
Route(47-68)
🔇 Additional comments (1)
ctx_test.go (1)
7481-7525: UpdateParam tests cover core behaviors wellThe two subtests validate the intended semantics: overriding an existing route param, ignoring unknown keys, and leaving Params unchanged when using a context on an app with no routing state. Use of
t.Parallel()is correct for both the parent test and subtests, and the in-handlerrequirechecks give precise guarantees aroundParamsandRoute().Params.
There was a problem hiding this comment.
Code Review
This pull request introduces the UpdateParam feature, which allows for overriding route parameters. The implementation is well-structured and includes comprehensive tests and benchmarks. My review focuses on a correctness issue related to case-sensitivity in UpdateParam that could lead to inconsistent behavior. I've also provided a suggestion to improve the new benchmark by simplifying it and ensuring proper resource cleanup. Overall, this is a great addition to the framework.
|
|
@TheAspectDev Pls also mention the new functionality with an example in the whats new md file |
|
@gaby @sixcolors @efectn |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🌐 Web query: 💡 Result: Short answer
How to do common tasks (examples)
Notes / caveats
References 🌐 Web query: 💡 Result: Quick summary — how common frameworks expose route params, whether they’re directly mutable, and their naming syntax:
Naming conventions: Node/JS frameworks commonly use colon-prefixed params (:id). Hapi uses curly braces ({id}). Go routers differ: Gin uses :name and /*wildcard; Chi uses {name}. Use each framework’s native style when defining routes to avoid mismatches. [1][2][3][4][5] Sources: [1] @koa/router docs; [2] hapi docs/npm; [3] Fastify docs; [4] Gin docs; [5] go-chi README. @ReneWerner87 Great question! Let me provide some context and alternatives: Express.js and JavaScript FrameworksIn Express.js, Other JavaScript frameworks follow similar patterns:
Since these expose params as plain objects, there's no dedicated "update method" – you just assign directly. Go FrameworksGin uses Possible Alternative Names for FiberGiven that Fiber uses explicit getter/setter patterns (like
RecommendationI'd suggest
However, What do you think? @gaby @sixcolors @efectn 🧠 Learnings used |
|
I like SetParam or OverrideParam |
|
|
@sixcolors @TheAspectDev ok with the new name? |
|
Yeah, |
Okay! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ctx_test.go (1)
8120-8140: Add a post‑loop assertion inBenchmark_Ctx_OverrideParamTo mirror other benchmarks in this file and ensure we’re not benchmarking a no‑op, it’s worth asserting the final param value after the loop (and incidentally documenting the expected behavior):
- Confirms
OverrideParamactually mutates the runtime values with the preparedRoute{Params: []string{"name","id"}}.- Aligns with existing benchmark style (e.g.
Benchmark_Ctx_Params,Benchmark_Ctx_Accepts*, etc.).You can do this without materially impacting benchmark semantics:
Proposed change
func Benchmark_Ctx_OverrideParam(b *testing.B) { app := New() ctx := app.AcquireCtx(&fasthttp.RequestCtx{}) c, ok := ctx.(*DefaultCtx) if !ok { b.Fatal("AcquireCtx did not return *DefaultCtx") } defer app.ReleaseCtx(c) c.values = [maxParams]string{"original", "12345"} c.route = &Route{Params: []string{"name", "id"}} c.setMatched(true) b.ReportAllocs() b.ResetTimer() for b.Loop() { c.OverrideParam("name", "changed") } + + // Sanity check that OverrideParam actually updated the value. + require.Equal(b, "changed", c.Params("name")) }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
ctx.goctx_interface_gen.goctx_test.godocs/api/ctx.mddocs/whats_new.md
🚧 Files skipped from review as they are similar to previous changes (2)
- ctx.go
- docs/api/ctx.md
🧰 Additional context used
📓 Path-based instructions (4)
**/*_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:
ctx_test.go
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
Prefer
github.com/gofiber/utils/v2helpers (for example,utils.Trim) when performing common operations such as string manipulation, whenever it is practical and appropriate for the surrounding code
Files:
ctx_test.goctx_interface_gen.go
docs/**
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Review and update the contents of the
docsfolder if necessary when modifying code
Files:
docs/whats_new.md
**/*.md
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Run
make markdownto lint all Markdown files when modifying code
Files:
docs/whats_new.md
🧠 Learnings (14)
📓 Common learnings
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-10-08T19:06:06.583Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
📚 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:
ctx_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:
ctx_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:
ctx_test.go
📚 Learning: 2024-11-10T23:44:13.704Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3193
File: middleware/adaptor/adaptor.go:111-111
Timestamp: 2024-11-10T23:44:13.704Z
Learning: In the `middleware/adaptor/adaptor.go` file of the Fiber framework, when updating context handling, replacing `c.Context()` with `c.RequestCtx()` is appropriate to access the `fasthttp.RequestCtx`.
Applied to files:
ctx_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:
ctx_test.go
📚 Learning: 2024-07-26T21:00:12.902Z
Learnt from: ReneWerner87
Repo: gofiber/fiber PR: 2864
File: ctx_test.go:4816-4816
Timestamp: 2024-07-26T21:00:12.902Z
Learning: The `ParamsInt` function's behavior, including handling empty string parameters, will be addressed in future PRs as per ReneWerner87's guidance.
Applied to files:
ctx_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:
ctx_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:
ctx_test.go
📚 Learning: 2024-09-25T17:09:03.756Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/middleware_test.go:400-407
Timestamp: 2024-09-25T17:09:03.756Z
Learning: In the `Test_Session_Next` function in `middleware/session/middleware_test.go`, the variable `doNext` is properly synchronized with the `muNext` mutex for both read and write access.
Applied to files:
ctx_test.go
📚 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:
ctx_test.go
📚 Learning: 2024-10-08T19:06:06.583Z
Learnt from: sixcolors
Repo: gofiber/fiber PR: 3016
File: middleware/session/store.go:164-167
Timestamp: 2024-10-08T19:06:06.583Z
Learning: Unit tests in this project use testify require.
Applied to files:
ctx_test.go
📚 Learning: 2024-10-16T14:00:50.724Z
Learnt from: gaby
Repo: gofiber/fiber PR: 3170
File: ctx.go:1825-1826
Timestamp: 2024-10-16T14:00:50.724Z
Learning: In the Fiber framework, the `IsProxyTrusted()` function returns `true` when `TrustProxy` is `false`, maintaining compatibility with version 2 behavior.
Applied to files:
ctx_test.go
📚 Learning: 2024-12-15T19:56:45.935Z
Learnt from: ckoch786
Repo: gofiber/fiber PR: 3230
File: docs/whats_new.md:944-951
Timestamp: 2024-12-15T19:56:45.935Z
Learning: Detailed usage examples and explanations for new methods like `RemoveRoute` and `RemoveRouteByName` are documented in `docs/api/app.md`, so it's unnecessary to duplicate them in `docs/whats_new.md`.
Applied to files:
docs/whats_new.md
🔇 Additional comments (3)
docs/whats_new.md (1)
570-570: LGTM! Clear and accurate documentation.The description accurately captures the method's behavior and is appropriately brief for this overview document. Based on learnings, detailed examples and usage are documented in the API docs (docs/api/ctx.md), which is the correct approach.
ctx_interface_gen.go (1)
122-124: LGTM! Interface addition is well-documented.The method comment clearly describes the overwrite behavior and explicitly states the no-op semantics when the parameter doesn't exist. Past review feedback has been addressed—the comment no longer includes unclear phrasing or implementation details. The method name "OverrideParam" is descriptive and the signature is straightforward.
ctx_test.go (1)
7481-7637: OverrideParam tests look comprehensive and match router semanticsThe
Test_Ctx_OverrideParamsubtests nicely cover:
- overriding existing vs non-existing params,
+and*wildcard params (including multi-wildcards),- case-sensitive vs case-insensitive routing,
- and the nil-router/no-route-matched case via a manually acquired
*DefaultCtx.The use of
t.Parallel()at the top of the main test and each subtest, plus properAcquireCtx/ReleaseCtxusage in thenil_routercase, is consistent with the rest of this file. I don’t see functional or style issues worth blocking on here.
This behavior is expected and tested in |
Yes it’s good. Thanks @ReneWerner87 |
|
Perfect, merge 🤩 |
|
Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Description
Allows
Ctx.OverrideParamto override existing route parameters while ignoring non-existing ones, and ensures proper behavior when using a nil router.This PR reflects the mutable req.params in
expressjsand adds corresponding tests and benchmarks to validate correctness and measure performance.Changes introduced
OverrideParam:OverrideParamctx.goandctx_interface_gen.goto satisfy lint rulesc.OverrideParamFixes #2118
Type of change
OverrideParamoverride behavior)🧾 Checklist