<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class BenchMarkMiddleware
{
    public function handle(Request $request, Closure $next)
    {

        $start = microtime(true);
        $response = $next($request);
        $end = microtime(true);
        if ($end - $start > 0.3) {
            Log::channel('benchmark')->info('rule hit', [
                'url' => $request->url(),
                'params' => $request->all()
            ]);
        }
        return $response;
    }
}
