Skip to content

Refactor routing core, introduce route collection and route finder to reduce router responsibilities#415

Merged
armanist merged 13 commits intosoftberg:masterfrom
armanist:412-Refactor-routing-core-introduce-RouteCollection-and-RouteFinder-to-reduce-Router-responsibilities
Feb 7, 2026
Merged

Refactor routing core, introduce route collection and route finder to reduce router responsibilities#415
armanist merged 13 commits intosoftberg:masterfrom
armanist:412-Refactor-routing-core-introduce-RouteCollection-and-RouteFinder-to-reduce-Router-responsibilities

Conversation

@armanist
Copy link
Member

@armanist armanist commented Feb 3, 2026

Routing Refactor (Breaking Change)

Summary

This PR introduces a breaking refactor of the routing system as part of the 3.0.0 stabilization work.

The focus is correctness, explicit behavior, and test coverage — not redesign.


What changed (high-impact)

  • Routing internals refactored to an object-based architecture:
    • Route
    • RouteCollection
    • MatchedRoute
    • RouteBuilder
    • RouteDispatcher
  • Route matching now produces a MatchedRoute stored on Request
  • Global route helpers (current_*, route_*) now read from MatchedRoute
  • Middleware ordering is strictly prepend-based and enforced by tests
  • Legacy static routing state and implicit controller resolution were removed
  • Extensive unit tests added for routing, helpers, and request integration

⚠️ Breaking changes to review carefully

Contributors should focus review effort on the following areas:

1. Controller resolution

  • Controllers are now instantiated directly from the route handler
  • Legacy RouteController-based resolution is no longer used
  • Verify namespace / FQCN expectations match real applications

2. RouteBuilder behavior

  • Grouping, middleware order, caching, and naming are enforced at build time
  • Route name uniqueness is validated during build

3. Request → routing boundary

  • MatchedRoute is nullable
  • Helpers must safely handle the “no route matched” case
  • Dispatcher is never invoked when no route is matched

What this PR does not do

  • ❌ No DSL changes
  • ❌ No backward-compatibility shims

How to review

Suggested review order:

  1. RouteBuilder and its unit tests
  2. Controller resolution logic in RouteDispatcher
  3. Route helper tests (expected runtime behavior)

This refactor affects core request flow — careful review is appreciated.

Closes #412

@codecov

This comment was marked as outdated.

@armanist armanist added enhancement New feature or request help wanted Extra attention is needed labels Feb 3, 2026
@armanist armanist added this to the 3.0.0 milestone Feb 3, 2026
Copy link
Collaborator

@andrey-smaelov andrey-smaelov left a comment

Choose a reason for hiding this comment

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

  1. There are several temp files were pushed (probably by accident) need to be removed
  2. There are several new error messages that appears all over the code, while need to be placed into ExceptionMessages class

@armanist armanist merged commit 6f0d37e into softberg:master Feb 7, 2026
6 checks passed
@armanist armanist deleted the 412-Refactor-routing-core-introduce-RouteCollection-and-RouteFinder-to-reduce-Router-responsibilities branch February 7, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor routing core: introduce RouteCollection and RouteFinder to reduce Router responsibilities

2 participants