Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Define routes that are accessible while in maintenance mode #24731

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Illuminate/Foundation/Console/DownCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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=* : Request URIs that shall be accessible while in maintenance mode.}';

/**
* The console command description.
Expand Down Expand Up @@ -52,6 +53,7 @@ protected function getDownFilePayload()
'message' => $this->option('message'),
'retry' => $this->getRetryTime(),
'allowed' => $this->option('allow'),
'except' => $this->option('except'),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public function handle($request, Closure $next)
return $next($request);
}

if (isset($data['except']) && in_array($request->getRequestUri(), (array) $data['except'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally expect to have exactly the same feature as \Illuminate\Foundation\Http\Middleware\VerifyCsrfToken::inExceptArray.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, thank you! This is even better.

return $next($request);
}

throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
}

Expand Down