router.config.php 963 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. *---------------------------------------------------------------
  4. * Router map configuration
  5. *---------------------------------------------------------------
  6. *
  7. * You can use this configuration to set you default application
  8. * routes.
  9. */
  10. return array(
  11. /*
  12. * Not Found and internal Server Error
  13. */
  14. '#404' => 'Error@404',
  15. '#500' => 'Error@500',
  16. /**
  17. * JSON response benchmark
  18. */
  19. 'json' => function()
  20. {
  21. return CCResponse::create( json_encode(
  22. array('message' => 'Hello, World!')
  23. ), 200 )->header( 'Content-Type', 'application/json' );
  24. },
  25. /**
  26. * JSON response benchmark
  27. */
  28. 'db' => function()
  29. {
  30. $queries = CCIn::get( 'queries', 1 );
  31. $worlds = array();
  32. for($i = 0; $i < $queries; ++$i)
  33. {
  34. $worlds[] = DB::select( 'World' )->find( mt_rand(1, 10000) );
  35. }
  36. return CCResponse::create( json_encode( $worlds ) )
  37. ->header( 'Content-Type', 'application/json' );
  38. },
  39. 'fortunes' => 'Bench@fortunes',
  40. );