Routing via annotation does not work for root endpoint

Issue #38 new
Dan created an issue

What did I do?

  • Routing is possible with method names or by annotations
  • Used routing via annotation for root endpoint (»Api\Route("/")«) and other endpoints (»@Api\Route("/acme-endpoint/")«)

What did I expect?

  • Controller routes all endpoints to expected controllers

What happend instead?

  • Root endpoint controllers is routed for all requests

Possible Reason

The regex to calculate the path to a matching method will always hit the »/« route, as it matches every route

https://bitbucket.org/99grad-team/nnrestapi/src/96bd5febbc00386791d5c16e7717a4f3fb6dbe60/Classes/Annotations/Route.php#lines-45

Possible solution

Compare the requested URI and handle requests for the root (»/«) differently.

Workaround

I removed the annotation routing and renamed the index controller to match the routing by method format.

Comments (2)

  1. Log in to comment