🔥 feat: Add support for configuring the Regex engine on the router - #4254
Conversation
- Created RegexEngine and RegexCompiler interfaces - Updated path.go to use configured regex engine - Added RegexEngine field to Config with DefaultRegexEngine - Updated router.go to pass RegexEngine to parseRoute - Added comprehensive tests for regex abstraction - Created example showing how to integrate coregex Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/3e2b7990-e9c5-41f6-afbf-ad29c8bbcfd0 Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4254 +/- ##
==========================================
+ Coverage 91.28% 91.33% +0.04%
==========================================
Files 132 132
Lines 13040 13087 +47
==========================================
+ Hits 11904 11953 +49
+ Misses 718 716 -2
Partials 418 418
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/3e2b7990-e9c5-41f6-afbf-ad29c8bbcfd0 Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
- Added regex-engines.md guide with coregex integration examples - Documented RegexEngine and RegexCompiler interfaces - Included performance benchmarks and use cases - Added custom implementation examples Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/3e2b7990-e9c5-41f6-afbf-ad29c8bbcfd0 Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
|
- Removed examples/regex-engine folder as requested - Updated docs/guide/regex-engines.md to remove reference to examples folder - All markdown linting issues resolved Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/9e71d891-0cc3-4786-8921-d994e500db6f Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Fixed in d7629bf:
|
|
@claude[agent] I'm not sure about the addition of I believe the approach should be as straightforward as our JSONEncoder and Decoder implementations within the app configuration. |
Moved regex types from separate regex.go file into path.go where they are used. This follows the simpler pattern similar to JSONEncoder/Decoder and reduces over-engineering by keeping related code together. Changes: - Removed regex.go and moved RegexEngine/RegexCompiler types to path.go - Moved tests from regex_test.go to path_test.go - All tests pass, no linting issues Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/175129f3-3f03-4a29-9673-b0521797d587 Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Simplified in ffc10c3. Removed the separate |
|
@claude[agent] Looking at the guide docs/guide/regex-engines.md and code. Using a different regex library is too complicated. We can simplify this. |
Following feedback to simplify the regex engine abstraction, this commit
refactors the implementation to use a simple function type instead of
interface-based approach.
Key changes:
- Replace RegexEngine interface with RegexHandler function type
- RegexHandler is now: func(pattern string) RegexCompiler
- Add defaultRegexHandler function that wraps regexp.MustCompile
- Update all references from RegexEngine to RegexHandler
- Simplify documentation to show direct usage without adapter types
This follows the same pattern as JSONEncoder/JSONDecoder in the codebase,
making it much simpler for users to adopt alternative regex engines:
Before (required adapter types):
type CoregexEngine struct{}
func (CoregexEngine) MustCompile(pattern string) fiber.RegexCompiler {...}
app := fiber.New(fiber.Config{RegexEngine: CoregexEngine{}})
After (just a function):
app := fiber.New(fiber.Config{
RegexHandler: func(pattern string) fiber.RegexCompiler {
return coregex.MustCompile(pattern)
},
})
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
|
@claude[agent] Why are you adding a handler, instead of just using // stdlib // coregex — same API The app config option should just take |
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/080c86b4-4942-4e6b-a12f-802358f0c71f Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
path_test.go:577
- Use Fiber status constants (e.g., StatusOK / StatusNotFound) instead of numeric literals to match the conventions used elsewhere in this test file.
require.Equal(t, 404, resp.StatusCode)
path_test.go:650
- Use StatusOK instead of the numeric literal 200 for consistency with other tests in this file.
require.Equal(t, 200, resp.StatusCode)
path_test.go:670
- Use StatusOK/StatusNotFound instead of numeric literals (200/404) for consistency with other tests in this file.
require.Equal(t, 200, resp.StatusCode)
resp, err = app.Test(httptest.NewRequest(http.MethodGet, "/date/2024-1-5", http.NoBody))
require.NoError(t, err)
require.Equal(t, 404, resp.StatusCode)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/11c807c8-6171-4884-a288-57a363969dee Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
|
@copilot fix markdownlint issues |
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/11c807c8-6171-4884-a288-57a363969dee Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gofiber/fiber/sessions/be55c783-8dee-4e54-a892-77f1a78864cc Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Addressed in 80078d8. markdownlint is clean now, and there isn’t an examples folder left in the current PR diff.
Addressed in 80078d8. I simplified the public surface so the feature is documented and exposed more directly instead of surfacing extra helper types.
Addressed in 80078d8. The guide and API docs now present this as a straightforward
Addressed in 80078d8. The config now stays focused on assigning
Fixed in 80078d8. markdownlint passes on the updated branch. |
|
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 |
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.