mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
* Added health controller * Trying to move session middleware to web and api group to have health controller without session * Fix health route store the session Co-authored-by: Vincent Lainé <v.laine@dental-monitoring.com>
This commit is contained in:
parent
2a817c2123
commit
d6ead5ae17
23
app/Http/Controllers/HealthController.php
Normal file
23
app/Http/Controllers/HealthController.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
|
||||
/**
|
||||
* This controller provide the healthz route for
|
||||
* the Snipe-IT Asset Management application.
|
||||
*
|
||||
* @version v1.0
|
||||
*/
|
||||
class HealthController extends BaseController
|
||||
{
|
||||
/**
|
||||
* Returns a fixed JSON content ({ "status": "ok"}) which indicate the app is up and running
|
||||
*/
|
||||
public function get() {
|
||||
return response()->json([
|
||||
"status" => "ok"
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ class Kernel extends HttpKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\App\Http\Middleware\NoSessionStore::class,
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
|
|
|
@ -27,7 +27,7 @@ class CheckForSetup
|
|||
}
|
||||
|
||||
} else {
|
||||
if (!($request->is('setup*')) && !($request->is('.env'))) {
|
||||
if (!($request->is('setup*')) && !($request->is('.env')) && !($request->is('health'))) {
|
||||
return redirect(url('/').'/setup');
|
||||
}
|
||||
|
||||
|
|
29
app/Http/Middleware/NoSessionStore.php
Normal file
29
app/Http/Middleware/NoSessionStore.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class NoSessionStore
|
||||
{
|
||||
protected $except = [
|
||||
'health'
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
foreach ($this->except as $except) {
|
||||
if ($request->is($except)) {
|
||||
config()->set('session.driver', 'array');
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -12,5 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
|
|||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'health'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -464,5 +464,4 @@ Route::group(['middleware' => 'web'], function () {
|
|||
|
||||
Auth::routes();
|
||||
|
||||
|
||||
|
||||
Route::get('/health', [ 'as' => 'health', 'uses' => 'HealthController@get']);
|
Loading…
Reference in a new issue