mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-04-20 23:41:52 +02:00
Add Cache Control middleware for #3479
This commit is contained in:
parent
7752529ac7
commit
d32f5e1aea
@ -15,6 +15,7 @@ use Barryvdh\Cors\HandleCors;
|
||||
use CachetHQ\Cachet\Http\Middleware\Admin;
|
||||
use CachetHQ\Cachet\Http\Middleware\ApiAuthentication;
|
||||
use CachetHQ\Cachet\Http\Middleware\Authenticate;
|
||||
use CachetHQ\Cachet\Http\Middleware\CacheControl;
|
||||
use CachetHQ\Cachet\Http\Middleware\Localize;
|
||||
use CachetHQ\Cachet\Http\Middleware\ReadyForUse;
|
||||
use CachetHQ\Cachet\Http\Middleware\RedirectIfAuthenticated;
|
||||
@ -47,6 +48,7 @@ class Kernel extends HttpKernel
|
||||
'admin' => Admin::class,
|
||||
'can' => Authorize::class,
|
||||
'cors' => HandleCors::class,
|
||||
'cache' => CacheControl::class,
|
||||
'auth' => Authenticate::class,
|
||||
'auth.api' => ApiAuthentication::class,
|
||||
'guest' => RedirectIfAuthenticated::class,
|
||||
|
36
app/Http/Middleware/CacheControl.php
Normal file
36
app/Http/Middleware/CacheControl.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CacheControl
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
$maxAge = time() + 30;
|
||||
|
||||
$response->header('Cache-Control', 'public,max-age='.$maxAge);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ class ApiSystemRoutes
|
||||
$router->group(['middleware' => ['auth.api']], function (Registrar $router) {
|
||||
$router->get('ping', 'GeneralController@ping');
|
||||
$router->get('version', 'GeneralController@version');
|
||||
$router->get('status', 'GeneralController@status');
|
||||
$router->get('status', ['uses' => 'GeneralController@status', 'middleware' => ['cache']]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user