Created
July 29, 2014 14:35
-
-
Save marcinlawnik/0a61c2974d4ccd73cfc2 to your computer and use it in GitHub Desktop.
maintenance filters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Simple maintenance filter for prefixes | |
//How to make it work for specific routes | |
// app/routes.php | |
/* | |
|-------------------------------------------------------------------------- | |
| Maintenance per-route Filter | |
|-------------------------------------------------------------------------- | |
*/ | |
Route::filter('prefix-maintenance', function(){ | |
if(in_array(Route::current()->getPrefix(), Config::get('maintenance.prefixes'))){ | |
//Do maintenance stuff | |
return Response::view('maintenance', array() , 503); | |
} | |
}); | |
//What should Route::current()->getPrefix() be replaced by? | |
Route::filter('route-maintenance', function(){ | |
if(in_array(Route::current()->getPrefix(), Config::get('maintenance.routes'))){ | |
//Do maintenance stuff | |
return Response::view('maintenance', array() , 503); | |
} | |
}); | |
// app/config/maintenance.php | |
<?php | |
return array( | |
//Routes to be in maintenance | |
'routes' => [ | |
'dev/test' | |
], | |
//Prefixes to be in maintenance | |
'prefixes' => [ | |
'dev' | |
] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment