Skip to content

feat(router): support custom path in ServiceRouter via RestController path property #398

Description

@usernane

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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