Skip to content

fix: reorder configureMiddleware before Boot so provider routes survive engine rebuild (#975)#1510

Merged
hwbrzzl merged 1 commit into
v1.17.xfrom
fix/v1.17-router-middleware-provider-route-loss
Jun 27, 2026
Merged

fix: reorder configureMiddleware before Boot so provider routes survive engine rebuild (#975)#1510
hwbrzzl merged 1 commit into
v1.17.xfrom
fix/v1.17-router-middleware-provider-route-loss

Conversation

@goravel-coder

Copy link
Copy Markdown
Contributor

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().

…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)
@goravel-coder
goravel-coder requested a review from a team as a code owner June 27, 2026 07:45
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v1.17.x@4e60a27). Learn more about missing BASE report.

Files with missing lines Patch % Lines
foundation/application.go 0.00% 1 Missing ⚠️
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.
📢 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.

@hwbrzzl
hwbrzzl merged commit c043037 into v1.17.x Jun 27, 2026
12 of 13 checks passed
@hwbrzzl
hwbrzzl deleted the fix/v1.17-router-middleware-provider-route-loss branch June 27, 2026 07:51
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.

2 participants