tc-php-mvc-core icon indicating copy to clipboard operation
tc-php-mvc-core copied to clipboard

Added findRoute() method to Router class

Open virtual-designer opened this issue 3 years ago • 1 comments

Think that our public/index.php file looks like this:

<?php
//...

$app->router->get('/test', [SiteController::class, 'test']);

//...

And now if we try to access route /test with method POST, then it will return 404 Not Found, which is not very good status for this case. The router should return 405 Method Not Allowed instead.

In this commit, I've added a method findRoute() which finds a route, and returns the route action, method and the URI.

@thecodeholic

virtual-designer avatar Jan 24 '22 11:01 virtual-designer

Well it seems to have some problems with routes that includes params for ex. '/user/{username}' it will still throw not found

RehabCZ avatar Jul 30 '23 09:07 RehabCZ