Skip to content

[P2][router] add route collision and shadowing diagnostics #61

Description

@redpeacock78

Summary

Route registration currently appends routes in order and dispatches by first match. That is simple and useful, but H-awk should warn about duplicate routes and likely shadowing once the framework grows route files/grouping/plugins.

Evidence

  • core/router.awk stores each route in ROUTES[method, path, ...] and appends registration order to ROUTES_ORDER.
  • Dispatch scans ROUTES_ORDER sequentially and runs the first matching route with the same method.
  • Dynamic segments such as /:id can shadow more specific routes registered later.

Proposed feature

  • Detect exact duplicate method + path registrations.
  • Warn when a dynamic route probably shadows a later static route.
  • Optionally expose hawk check diagnostics for route tables.
  • Add a debug command to print route order and compiled regex patterns.

Acceptance criteria

  • Duplicate route registration is detected.
  • Common shadowing cases are reported with file/line info if available.
  • Users can intentionally suppress/allow a duplicate route when needed.
  • Tests cover exact duplicate, static-before-dynamic, and dynamic-before-static order.

Priority: P2
Area: router/diagnostics
Type: feature

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions