routes.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | Application Routes
  5. |--------------------------------------------------------------------------
  6. |
  7. | Here is where you can register all of the routes for an application.
  8. | It's a breeze. Simply tell Laravel the URIs it should respond to
  9. | and give it the Closure to execute when that URI is requested.
  10. |
  11. */
  12. Route::get('/', function()
  13. {
  14. return View::make('hello');
  15. });
  16. // Route::controller(Controller::detect());
  17. Route::get('/json', function()
  18. {
  19. return Response::json(array('message' => 'Hello, World!'));
  20. });
  21. Route::get('/plaintext', function()
  22. {
  23. return "Hello, World!";
  24. });
  25. Route::get('/db', function()
  26. {
  27. $queries = Input::get('queries', 1);
  28. $worlds = array();
  29. for($i = 0; $i < $queries; ++$i) {
  30. $worlds[] = DB::table('World')->find(mt_rand(1, 10000));
  31. }
  32. return Response::json($worlds);
  33. });
  34. Route::get('/fortunes', 'BenchController@fortunes');
  35. // /*
  36. // |--------------------------------------------------------------------------
  37. // | Application 404 & 500 Error Handlers
  38. // |--------------------------------------------------------------------------
  39. // |
  40. // | To centralize and simplify 404 handling, Laravel uses an awesome event
  41. // | system to retrieve the response. Feel free to modify this function to
  42. // | your tastes and the needs of your application.
  43. // |
  44. // | Similarly, we use an event to handle the display of 500 level errors
  45. // | within the application. These errors are fired when there is an
  46. // | uncaught exception thrown in the application. The exception object
  47. // | that is captured during execution is then passed to the 500 listener.
  48. // |
  49. // */
  50. // Event::listen('404', function()
  51. // {
  52. // return Response::error('404');
  53. // });
  54. // Event::listen('500', function($exception)
  55. // {
  56. // return Response::error('500');
  57. // });
  58. // /*
  59. // |--------------------------------------------------------------------------
  60. // | Route Filters
  61. // |--------------------------------------------------------------------------
  62. // |
  63. // | Filters provide a convenient method for attaching functionality to your
  64. // | routes. The built-in before and after filters are called before and
  65. // | after every request to your application, and you may even create
  66. // | other filters that can be attached to individual routes.
  67. // |
  68. // | Let's walk through an example...
  69. // |
  70. // | First, define a filter:
  71. // |
  72. // | Route::filter('filter', function()
  73. // | {
  74. // | return 'Filtered!';
  75. // | });
  76. // |
  77. // | Next, attach the filter to a route:
  78. // |
  79. // | Route::get('/', array('before' => 'filter', function()
  80. // | {
  81. // | return 'Hello World!';
  82. // | }));
  83. // |
  84. // */
  85. // Route::filter('before', function()
  86. // {
  87. // // Do stuff before every request to your application...
  88. // });
  89. // Route::filter('after', function($response)
  90. // {
  91. // // Do stuff after every request to your application...
  92. // });
  93. // Route::filter('csrf', function()
  94. // {
  95. // if (Request::forged()) return Response::error('500');
  96. // });
  97. // Route::filter('auth', function()
  98. // {
  99. // if (Auth::guest()) return Redirect::to('login');
  100. // });