Custom site routes not being hit

First up, apologies for what already seems like a Kirby n00b Q! I have only just started playing with it.

I am exploring alternate methods for building a sensible api with kirby to work with either Angular 1 or ReactJs…

I have managed to build a very basic api using invisible routes no problem, but now want to be able to use the built in routes options…

From the docs:
http://getkirby.com/docs/advanced/routing

c::set('routes', array(
  array(
    'pattern' => 'my/awesome/url',
    'action'  => function() {
      // do something here when the URL matches the pattern above
    }
  )
));

When i drop this snippet of code into the main site config file I cannot get the route to match… here is my snippet:

/**
 * Custom routing
 */
c::set('routes', array(
    array(
        'pattern' => 'john/(:any)/(:num)/(:all)',
        'action'  => function( $anyPlaceholder, $numPlaceholder, $allPlaceholder ) {
            // do something here when the URL matches the pattern above

            /*print_r( $anyPlaceholder );
            print_r( $numPlaceholder );
            print_r( $allPlaceholder );*/

            die('x');

            /*return response::json(array(
                'some', 'json', 'stuff'
            ));*/
        },
        'method' => 'GET|POST|DELETE'
    )
));

You would expect the route to be hit and and x printed to screen. However I can only get the error page.

Is there more to registering new routes than simply dropping them into the ‘site/config/config.php’ file?

Cheers,
John

Generally this should already work. Have you tried using a very simple pattern without placeholders to test if routes work in general?

/**
 * Custom routing
 */
c::set('routes', array(
    array(
        'pattern' => 'john/',
        'action'  => function(  ) {
            // do something here when the URL matches the pattern above
            die( 'xxx' );
        },
        'method' => 'GET|POST|DELETE'
    )
));

OK, I set up a proper vhost and it all magically worked… localhost was not playing nice for some reason eg.

php -S localhost:8000