misc_pterodactyl-panel/app/Http/Middleware/MaintenanceMiddleware.php

43 lines
909 B
PHP
Raw Permalink Normal View History

2018-05-04 13:02:51 +00:00
<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
2018-05-26 18:00:28 +00:00
use Illuminate\Contracts\Routing\ResponseFactory;
2018-05-04 13:02:51 +00:00
class MaintenanceMiddleware
{
2018-05-26 18:00:28 +00:00
/**
* @var \Illuminate\Contracts\Routing\ResponseFactory
*/
private $response;
/**
* MaintenanceMiddleware constructor.
*/
public function __construct(ResponseFactory $response)
{
$this->response = $response;
}
2018-05-04 13:02:51 +00:00
/**
* Handle an incoming request.
*
2018-05-26 18:00:28 +00:00
* @param \Illuminate\Http\Request $request
2021-01-23 20:33:34 +00:00
*
2018-05-04 13:02:51 +00:00
* @return mixed
*/
public function handle($request, Closure $next)
{
2018-05-26 18:00:28 +00:00
/** @var \Pterodactyl\Models\Server $server */
2018-05-04 13:02:51 +00:00
$server = $request->attributes->get('server');
2018-05-26 18:00:28 +00:00
$node = $server->getRelation('node');
2018-05-04 13:02:51 +00:00
if ($node->maintenance_mode) {
2018-05-26 18:00:28 +00:00
return $this->response->view('errors.maintenance');
2018-05-04 13:02:51 +00:00
}
return $next($request);
}
}