Start of hook to check for version updates

This commit is contained in:
Deon George 2023-03-02 09:55:33 +11:00
parent 64d1a09db4
commit ee556582d2
2 changed files with 41 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Kernel as HttpKernel;
use App\Http\Middleware\GuestUser;
use App\Http\Middleware\SwapinAuthUser;
use App\Http\Middleware\CheckUpdate;
class Kernel extends HttpKernel
{
@ -43,6 +44,7 @@ class Kernel extends HttpKernel
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
GuestUser::class,
CheckUpdate::class,
],
'api' => [

View 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;
});
}
}