Skip to content

Instantly share code, notes, and snippets.

@marcinlawnik
Created July 29, 2014 14:35
Show Gist options
  • Save marcinlawnik/0a61c2974d4ccd73cfc2 to your computer and use it in GitHub Desktop.
Save marcinlawnik/0a61c2974d4ccd73cfc2 to your computer and use it in GitHub Desktop.
maintenance filters
//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