Start of hook to check for version updates
This commit is contained in:
parent
64d1a09db4
commit
ee556582d2
@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
|||||||
|
|
||||||
use App\Http\Middleware\GuestUser;
|
use App\Http\Middleware\GuestUser;
|
||||||
use App\Http\Middleware\SwapinAuthUser;
|
use App\Http\Middleware\SwapinAuthUser;
|
||||||
|
use App\Http\Middleware\CheckUpdate;
|
||||||
|
|
||||||
class Kernel extends HttpKernel
|
class Kernel extends HttpKernel
|
||||||
{
|
{
|
||||||
@ -43,6 +44,7 @@ class Kernel extends HttpKernel
|
|||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
|
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
|
||||||
GuestUser::class,
|
GuestUser::class,
|
||||||
|
CheckUpdate::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
39
app/Http/Middleware/CheckUpdate.php
Normal file
39
app/Http/Middleware/CheckUpdate.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class CheckUpdate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle($request, Closure $next)
|
||||||
|
{
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle tasks after the response has been sent to the browser.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Illuminate\Http\Response $response
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function terminate($request, $response)
|
||||||
|
{
|
||||||
|
Cache::remember('version',60*5,function() {
|
||||||
|
// CURL call to URL to see if there is a new version
|
||||||
|
Log::debug(sprintf('Checking for updates for [%s]',config('app.version')));
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user