A callable can be passed in place of $options. In this case the callable acts as a *route
handler*. Route handlers should return an instance of lithium\net\http\Response
and can be used to short-circuit the framework's lookup and invocation of controller
actions:
Router::connect('/photos/{:id:[0-9]+}.jpg', array(), function($request) {
return new Response(array(
'headers' => array('Content-type' => 'image/jpeg'),
'body' => Photos::first($request->id)->bytes()
));
});
public static connect ( string | object $template, array | string $params = [], array | callable $options = [] ) : array | ||
$template | string | object | An empty string, a route string `/` or an instance of `lithium\net\http\Route`. |
$params | array | string | An array describing the default or required elements of the route or alternatively a path string i.e. `Posts::index`. |
$options | array | callable | Either an array of options (`'handler'`, `'formatters'`, `'modifiers'`, `'unicode'` as well as any options for `Route`) or a callable that will be used as a route handler. |
return | array | Array of routes |