Skip to content

feat: add RouteOption::NAMESPACE for dynamic service resolution #383

@usernane

Description

@usernane

Step 2 of 5: ServiceRouter integration (ADR-0006)

Problem

Some architectures (plugin systems, rapid prototyping) need services to be discoverable at runtime without restarting or clearing cache.

Proposed Change

Add RouteOption::NAMESPACE that enables dynamic resolution:

Router::api([
    RouteOption::PATH => '/apis/{controller}',
    RouteOption::NAMESPACE => 'App\\Apis',
    RouteOption::MIDDLEWARE => [...]
]);

When a request hits /apis/orders, the framework:

  1. Extracts {controller} = orders
  2. Scans App\Apis for a class with #[RestController('orders')]
  3. Instantiates it and delegates to RequestProcessor

Acceptance Criteria

  • RouteOption::NAMESPACE accepted by Router
  • Dynamic resolution of controller name → class at request time
  • Returns 404 if no matching #[RestController] found
  • Works alongside existing route types

Backward Compatibility

New route option — no breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprove performace or existing feature.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions