fix: reorder configureMiddleware before Boot so provider routes survive engine rebuild (#975)#1510
Merged
Conversation
…ve engine rebuild (#975) In Build(), configureMiddleware was called after Boot(), which means routes registered by service providers during Boot() were silently dropped when SetGlobalMiddleware rebuilt the route engine. Moving configureMiddleware between Register() and Boot() ensures the engine is set up with global middleware before providers register their routes. Fixes goravel/goravel#975 (cherry picked from commit on master)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.17.x #1510 +/- ##
==========================================
Coverage ? 68.69%
==========================================
Files ? 281
Lines ? 17766
Branches ? 0
==========================================
Hits ? 12205
Misses ? 5056
Partials ? 505 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backport of #1508 to v1.17.x.
Fixes goravel/goravel#975
Routes registered inside a ServiceProvider.Boot() (e.g. app.MakeRoute().Get(...)) were silently discarded when the application registered any global middleware via WithMiddleware() in bootstrap/app.go. The routes returned 404 at runtime with no error.
Root Cause
In Build(), configureMiddleware() was called after Boot(). When WithMiddleware is used, SetGlobalMiddleware rebuilds the route engine. Routes registered by providers during Boot() were on the old engine and lost.
Fix
Reorder configureMiddleware() to run between Register() and Boot() instead of after Boot().