$obj->microtime = microtime(true); $obj->param = $param; return $obj; }); /** * Return the view data as a json object * Fetch the registsered on-demand "mockdb" object from the app * Note that the mockdb objects are the different because it was registered with ->demand() * If it was registered with ->share() it would be created only once */ $app->route('json', '/json', function (App $app) { $response = $app->response(); $response['user'] = '******'; $response['user_id'] = 1; $response['registered'] = true; $response['mockdb_obj'] = $app->mockdb(1); $response['mockdb_obj2'] = $app->mockdb(16); $response->set_renderer(JSONRenderer::create('', $app)); return $response->render(); }); /** * Create a basic test page for different accept header requests */ $app->route('accept', '/accept', function (Response $response) { $response['message'] = 'The result of the demo appears here. This is from HTML.'; return $response->render('accept.php'); }); $app->route('accecpt_json', '/accept', function (Response $response, App $app) { $response->set_renderer(JSONRenderer::create('', $app)); $response['message'] = 'The result of the demo appears here. This is from JSON.'; return $response;