Files
nl-admin-api/app/Http/Middleware/MaintenanceMiddleware.php

46 lines
841 B
PHP
Raw Normal View History

2014-10-06 15:25:53 -05:00
<?php namespace App\Http\Middleware;
2014-08-20 00:10:30 -05:00
2014-10-06 15:25:53 -05:00
use Closure;
2014-09-23 08:31:57 -05:00
use Illuminate\Http\Response;
2014-10-06 15:25:53 -05:00
use Illuminate\Contracts\Routing\Middleware;
2014-09-22 20:21:58 -05:00
use Illuminate\Contracts\Foundation\Application;
2014-08-11 10:13:20 -05:00
2014-10-06 15:25:53 -05:00
class MaintenanceMiddleware {
2014-08-11 10:13:20 -05:00
2014-09-22 20:21:58 -05:00
/**
* The application implementation.
*
* @var Application
*/
protected $app;
/**
* Create a new filter instance.
*
* @param Application $app
* @return void
*/
2014-09-23 08:31:57 -05:00
public function __construct(Application $app)
2014-09-22 20:21:58 -05:00
{
$this->app = $app;
}
2014-08-11 10:13:20 -05:00
/**
2014-10-06 15:25:53 -05:00
* Handle an incoming request.
2014-08-11 10:13:20 -05:00
*
2014-10-06 15:25:53 -05:00
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
2014-08-11 10:13:20 -05:00
*/
2014-10-06 15:25:53 -05:00
public function handle($request, Closure $next)
2014-08-11 10:13:20 -05:00
{
2014-09-22 20:21:58 -05:00
if ($this->app->isDownForMaintenance())
2014-08-11 10:13:20 -05:00
{
2014-09-23 08:31:57 -05:00
return new Response('Be right back!', 503);
2014-08-11 10:13:20 -05:00
}
2014-10-06 15:25:53 -05:00
return $next($request);
2014-08-11 10:13:20 -05:00
}
2014-09-21 20:31:42 +01:00
}