Skip to content

feat(routing): L13 route-middleware engine alongside legacy filters (task 2.8, part 1) - #55

Open
agissept wants to merge 2 commits into
migration/2.12-cookie-jar-widenfrom
migration/2.8-routing-middleware-engine
Open

agissept wants to merge 2 commits into
migration/2.12-cookie-jar-widenfrom
migration/2.8-routing-middleware-engine

Conversation

@agissept

Copy link
Copy Markdown
Member

Task 2.8 (part 1) — route-middleware engine [fork]

Menyalakan mesin route-middleware L13 yang benar-benar jalan, berdampingan dgn filter lama, supaya app bisa migrasi filter→middleware per-route tanpa menghapus filter apa pun dulu. Ini prasyarat aman untuk konversi app (jalur A).

Yang ditambah (additive)

  • Route::middleware() / gatherMiddleware() — simpan nama middleware di route.
  • Registry Router: aliasMiddleware(), middlewareGroup(), middlewarePriority() + resolveMiddleware/gatherRouteMiddleware/uniqueMiddleware.
  • runRouteWithinStack() — jalankan route lewat Illuminate\Pipeline\Pipeline (sudah ada dari task 1.2), di dalam bracket filter callRouteBefore/After.
  • File baru copy dari L13: MiddlewareNameResolver (alias/group/param :), SortedMiddleware (priority).
  • dispatchToRoute: swap 1 baris route->run($request)runRouteWithinStack().

Kenapa aman untuk 52 guard (krusial)

Route tanpa ->middleware() → middleware kosong → short-circuit ke run() biasa → perilaku identik untuk semua route eksisting. Terbukti: 66 test routing lama lolos tanpa perubahan. Filter tetap utuh; middleware & filter di registry terpisah → sintaks : tak tabrakan. Exception nembus ke handler top-level (base Pipeline rethrow); routing-Pipeline HTTP-aware (ExceptionHandler/Responsable) ditunda ke SCC-1.

Ditunda (SCC-1 lockstep)

Hapus surface filter, Http\Kernel + config middleware groups/priority, controller-middleware — semua mendarat bareng konversi filter→middleware app (yang konsumsi ini via alias dev-dev-13).

Verifikasi

tests/Routing 68 hijau (66 lama + 2 baru: closure/short-circuit/alias/param/group + koeksis-dgn-filter). Foundation (34) & Http (61) hijau. Lint bersih.

Urutan

Stacked di atas #54 (stack: #45#46#48#52#53#54ini). Blocker (1.1, 1.2 Pipeline) ✅.

🤖 Generated with Claude Code

…rs (task 2.8, part 1)

Introduce a running route-middleware stack so the app can migrate filters ->
middleware route-by-route, WITHOUT removing any filter yet.

- Route::middleware()/gatherMiddleware() store middleware names on the route.
- Router middleware registry (aliasMiddleware/middlewareGroup/middlewarePriority)
  + resolveMiddleware/gatherRouteMiddleware/uniqueMiddleware.
- runRouteWithinStack() runs the route through Illuminate\Pipeline\Pipeline
  (already present from task 1.2) INSIDE the legacy before/after filter bracket.
- New leaves copied from L13: MiddlewareNameResolver (alias/group/':' params),
  SortedMiddleware (priority sort).
- dispatchToRoute: one-line swap route->run($request) -> runRouteWithinStack().

Safety: routes with no ->middleware() short-circuit to a plain run() -> behavior
is identical for every existing (filter-only) route (66 existing routing tests
unchanged). Filters stay intact; middleware and filters use SEPARATE registries
so the ':' param syntax does not collide. Exceptions propagate to the existing
top-level handler (base Pipeline rethrows); the HTTP-aware routing Pipeline is
deferred to SCC-1.

Deferred (SCC-1 lockstep): removing the filter surface, Http\Kernel + middleware
groups/priority config, controller middleware -- these land together with the
app's filters->middleware conversion that consumes this via the dev-13 alias.

Tests: +testRouteMiddlewareRunsAndWraps (closure/short-circuit/alias/param/group),
+testRouteMiddlewareCoexistsWithFilters. tests/Routing green (68), Foundation/Http green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@agissept agissept self-assigned this Sep 15, 2026
…lters (task 2.8)

Add Controller::middleware($middleware, array $options = []) — matches L13's exact
signature. Bridges to beforeFilter() so controller-declared middleware runs via the
existing ControllerDispatcher filter path until the routing engine is swapped to
stock L13. Lets the app flip $this->beforeFilter('x') -> $this->middleware('x')
(options incl. only/except carry over unchanged after the swap). Additive;
beforeFilter() untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant