Problem Statement
ServiceRouter::discover() derives route paths from directory structure and class names. There is no way to set a custom multi-segment path (e.g. auth/login) for a service because the #[RestController] attribute only has a name property which rejects slashes.
Proposed Solution
Once WebFiori/http#141 adds the path property to #[RestController], update ServiceRouter::scanNamespace() to use it:
if (!empty($attr->path)) {
$routePath = $attr->path; // custom multi-segment path
} else if (!empty($attr->name)) {
$routePath = $attr->name; // flat name (no slashes)
} else {
$routePath = $pathPrefix . self::deriveNameFromClass($className); // auto-derived
}
Alternatives Considered
- Allow slashes in
name — conflates service identity with URL path.
Breaking Change
No
Additional Context
Depends on: WebFiori/http#141
Problem Statement
ServiceRouter::discover()derives route paths from directory structure and class names. There is no way to set a custom multi-segment path (e.g.auth/login) for a service because the#[RestController]attribute only has anameproperty which rejects slashes.Proposed Solution
Once WebFiori/http#141 adds the
pathproperty to#[RestController], updateServiceRouter::scanNamespace()to use it:Alternatives Considered
name— conflates service identity with URL path.Breaking Change
No
Additional Context
Depends on: WebFiori/http#141