Search code examples
routeslithium

Why is lithium's (li3) last-route not catching everything?


The last connect on the Lithium Router:

Router::connect('/{:controller}/{:action}/{:args}', 'Main::end');

Should match all the routes? No? But instead of execute my Main::end method (who simply exit('with some text, for testing...')), Lithium give to me a dispatcher exception T_T:

 lithium\action\DispatchException (code 404)
 Controller `Sdsa` not found.
 path_to_my_root/libraries/lithium/action/Dispatcher.php: 239

What i'm doing wrong?


Solution

  • Solved my self issue by using a standard regex:

    Router::connect('/(.*)', 'Main::end');
    

    that will process all the requests to Main::end.

    As Nils says, my actual solution is not perfect because of the lack of 404 pages handling...

    Because i'm trying to use Backbone.js, maybe i could handle the 404 pages client side like this: How to have a fallback route to catch unknown pages in backbone.js