From e0d23c7f2b4859687300d1e3f65188114a301ab0 Mon Sep 17 00:00:00 2001 From: thannaske Date: Tue, 3 Jul 2018 00:29:27 +0200 Subject: [PATCH 1/2] Add possibility to define routes that are accessible during maintenance mode --- src/Illuminate/Foundation/Console/DownCommand.php | 6 ++++-- .../Foundation/Http/Middleware/CheckForMaintenanceMode.php | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 4382ccc2e1d5..008f012fdc70 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -14,9 +14,10 @@ class DownCommand extends Command * * @var string */ - protected $signature = 'down {--message= : The message for the maintenance mode. } + protected $signature = 'down {--message= : The message for the maintenance mode.} {--retry= : The number of seconds after which the request may be retried.} - {--allow=* : IP or networks allowed to access the application while in maintenance mode.}'; + {--allow=* : IP or networks allowed to access the application while in maintenance mode.} + {--except=* : Names of routes that shall be accessible while in maintenance mode.}'; /** * The console command description. @@ -52,6 +53,7 @@ protected function getDownFilePayload() 'message' => $this->option('message'), 'retry' => $this->getRetryTime(), 'allowed' => $this->option('allow'), + 'except' => $this->option('except'), ]; } diff --git a/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php b/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php index ca1af7269a82..c57318892970 100644 --- a/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php +++ b/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php @@ -45,6 +45,10 @@ public function handle($request, Closure $next) return $next($request); } + if (isset($data['except']) && in_array($request->getRequestUri(), (array) $data['except'])) { + return $next($request); + } + throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']); } From ccbad861c62029a03ce85d84bee7515b871b0330 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 3 Jul 2018 17:59:25 +0200 Subject: [PATCH 2/2] Fixing the wording of the command description --- src/Illuminate/Foundation/Console/DownCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Console/DownCommand.php b/src/Illuminate/Foundation/Console/DownCommand.php index 008f012fdc70..17f576ae9554 100644 --- a/src/Illuminate/Foundation/Console/DownCommand.php +++ b/src/Illuminate/Foundation/Console/DownCommand.php @@ -17,7 +17,7 @@ class DownCommand extends Command protected $signature = 'down {--message= : The message for the maintenance mode.} {--retry= : The number of seconds after which the request may be retried.} {--allow=* : IP or networks allowed to access the application while in maintenance mode.} - {--except=* : Names of routes that shall be accessible while in maintenance mode.}'; + {--except=* : Request URIs that shall be accessible while in maintenance mode.}'; /** * The console command description.