routes.php 2.7 KB
Newer Older
1 2
<?php

3 4 5 6 7 8
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a
9 10
| breeze to setup your application using Laravel's RESTful routing and it
| is perfectly suited for building large applications and simple APIs.
11 12 13
|
| Let's respond to a simple GET request to http://example.com/hello:
|
14
|		Route::get('hello', function()
15 16 17 18 19 20
|		{
|			return 'Hello World!';
|		});
|
| You can even respond to more than one URI:
|
21
|		Route::post(array('hello', 'world'), function()
22 23 24 25 26 27
|		{
|			return 'Hello World!';
|		});
|
| It's easy to allow URI wildcards using (:num) or (:any):
|
28
|		Route::put('hello/(:any)', function($name)
29 30 31 32 33
|		{
|			return "Welcome, $name.";
|		});
|
*/
34

35
Route::get('/', function()
36 37 38
{
	return View::make('home.index');
});
39

40 41
/*
|--------------------------------------------------------------------------
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Application 404 & 500 Error Handlers
|--------------------------------------------------------------------------
|
| To centralize and simplify 404 handling, Laravel uses an awesome event
| system to retrieve the response. Feel free to modify this function to
| your tastes and the needs of your application.
|
| Similarly, we use an event to handle the display of 500 level errors
| within the application. These errors are fired when there is an
| uncaught exception thrown in the application.
|
*/

Event::listen('404', function()
{
	return Response::error('404');
});

Event::listen('500', function()
{
	return Response::error('500');
});

/*
|--------------------------------------------------------------------------
67 68 69 70
| Route Filters
|--------------------------------------------------------------------------
|
| Filters provide a convenient method for attaching functionality to your
71 72 73
| routes. The built-in before and after filters are called before and
| after every request to your application, and you may even create
| other filters that can be attached to individual routes.
74 75 76 77 78
|
| Let's walk through an example...
|
| First, define a filter:
|
79
|		Route::filter('filter', function()
80 81 82 83 84 85 86 87 88 89 90 91
|		{
|			return 'Filtered!';
|		});
|
| Next, attach the filter to a route:
|
|		Router::register('GET /', array('before' => 'filter', function()
|		{
|			return 'Hello World!';
|		}));
|
*/
92

93
Route::filter('before', function()
94 95 96 97
{
	// Do stuff before every request to your application...
});

98
Route::filter('after', function($response)
99 100 101 102
{
	// Do stuff after every request to your application...
});

103
Route::filter('csrf', function()
104 105 106 107
{
	if (Request::forged()) return Response::error('500');
});

108
Route::filter('auth', function()
109 110 111
{
	if (Auth::guest()) return Redirect::to('login');
});