Skip to content

Feature implementation from commits fa70d2b..0c6283f#2

Open
yashuatla wants to merge 15 commits into
feature-base-2from
feature-head-2
Open

Feature implementation from commits fa70d2b..0c6283f#2
yashuatla wants to merge 15 commits into
feature-base-2from
feature-head-2

Conversation

@yashuatla
Copy link
Copy Markdown
Owner

@yashuatla yashuatla commented Jun 25, 2025

PR Summary

Bug Fixes and Route Management Enhancements

Overview

This PR addresses several bugs in the request header handling and test reliability while adding new route management capabilities to the App struct.

Change Types

Type Description
Bugfix Fixed error handling in GetReqHeader function
Bugfix Improved test reliability by using local test server instead of external URLs
Enhancement Added route management functionality to App struct
Refactor Removed unused imports and fixed function parameter

Affected Modules

Module / File Change Description
ctx.go Fixed error handling in GetReqHeader function
ctx_test.go Removed unused imports "context" and "math"
proxy/proxy_test.go Improved test reliability using local test server
timeout/timeout_test.go Fixed parameter in sleepWithContext function call
router.go Added new route management functions (normalizePath, RemoveRoute, etc.)

Notes for Reviewers

  • The GetReqHeader function now properly handles errors from genericParseType
  • Test_Proxy_Do_WithRealURL no longer makes external HTTP requests, improving test reliability
  • New route removal functionality has been added to the App struct

ckoch786 and others added 15 commits May 21, 2025 09:45
* 🔥 feat: Add Support for Removing Routes (gofiber#3230)

* Add new methods named RemoveRoute and RemoveRouteByName.

* Update register method to prevent duplicate routes.

* Clean up tests

* Update docs

* Update router.go

* Fix markdown

* Some fixes

* update

* test

* fix removing logic

* fix tests

* fix tests

* update docs

* fix tests

* Update docs/api/app.md

* Apply suggestions from code review

* update methods behavior of removeroute

* 🔥 feat: Add Support for Removing Routes gofiber#3230

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Co-authored-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com>
Co-authored-by: Muhammed Efe Cetin <efectn@protonmail.com>
Co-authored-by: RW <rene@gofiber.io>
* Expand Test_Utils_Parse_Address

* Update implementation based on Codex

* Remove duplicated func

* Update test fmt

* format

* Update helpers_test.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* more format

* more format

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…#3467)

* Fix proxy middleware tests to avoid external network

* Update proxy_test.go

* Update middleware/proxy/proxy_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update proxy_test.go

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ofiber#3440)

* build(deps): bump github.com/valyala/fasthttp from 1.60.0 to 1.62.0

Bumps [github.com/valyala/fasthttp](https://github.com/valyala/fasthttp) from 1.60.0 to 1.62.0.
- [Release notes](https://github.com/valyala/fasthttp/releases)
- [Commits](valyala/fasthttp@v1.60.0...v1.62.0)

---
updated-dependencies:
- dependency-name: github.com/valyala/fasthttp
  dependency-version: 1.62.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix CSRF middleware tests for fasthttp 1.62 (gofiber#3471)

Fix CSRF tests for fasthttp 1.62

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: RW <rene@gofiber.io>
adpater / HTTPHandler
NEW
Benchmark_HTTPHandler-12    	 1762837	       640.6 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1924524	       616.5 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1838780	       650.4 ns/op	     696 B/op	      10 allocs/op
Benchmark_HTTPHandler-12    	 1876947	       644.0 ns/op	     696 B/op	      10 allocs/op
OLD
Benchmark_HTTPHandler-12    	 1864819	       667.2 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1892569	       677.0 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1811704	       639.5 ns/op	     720 B/op	      11 allocs/op
Benchmark_HTTPHandler-12    	 1879849	       644.0 ns/op	     720 B/op	      11 allocs/op

Utils / IsNoCache
NEW
Benchmark_Utils_IsNoCache-12    	44307204	        27.08 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	40782919	        26.88 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	44228217	        26.69 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	45605700	        26.75 ns/op	       0 B/op	       0 allocs/op
OLD
Benchmark_Utils_IsNoCache-12    	30043908	        37.80 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	32137476	        37.51 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	31474653	        37.92 ns/op	       0 B/op	       0 allocs/op
Benchmark_Utils_IsNoCache-12    	31838683	        37.71 ns/op	       0 B/op	       0 allocs/op
* ♻️ refact: make genericParseType return error

* 🐛 fix: return error when parsing unsupported type

* 🚨 test: cover the default value for Params

* 🚨 test: cover default value on parsing error

* ♻️ refact: change the benchmark name

* 🚨 test: remove the duplicated maxUint16 test case

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
* Ctx implements context.Context

* fix up some linting issues

* added some tests

* no message

* fiber.Ctx implements context.Context

* no message

* implement compile-time check

* update formatting

* update compile-time checks

---------

Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Comment thread router.go
removedUseRoutes[route.path] = struct{}{}
}

atomic.AddUint32(&app.handlersCount, ^uint32(len(route.Handlers)-1)) //nolint:gosec // Not a concern
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Potentially confusing atomic decrement operation.

The atomic decrement using bitwise complement (^uint32) is an uncommon pattern that could lead to incorrect handler counting and application instability.

Current Code (Diff):

- 				atomic.AddUint32(&app.handlersCount, ^uint32(len(route.Handlers)-1)) //nolint:gosec // Not a concern
+ 				atomic.AddUint32(&app.handlersCount, ^uint32(0) - uint32(len(route.Handlers)-1)) //nolint:gosec // Not a concern
📝 Committable suggestion

‼️ IMPORTANT
Trust, but verify! 🕵️ Please review this suggestion with the care of a code archaeologist - check that it perfectly replaces the highlighted code, preserves all lines, maintains proper indentation, and won't break anything in production. Your future self will thank you! 🚀

Suggested change
atomic.AddUint32(&app.handlersCount, ^uint32(len(route.Handlers)-1)) //nolint:gosec // Not a concern
atomic.AddUint32(&app.handlersCount, ^uint32(0) - uint32(len(route.Handlers)-1)) //nolint:gosec // Not a concern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants