i am trying to measure the data size of all incoming and out going request using a middleware in laravel. This will help me know the internet data my application is using. the problem is that i cannot get access to data being sent from my server to the client or browser and i think it is because i am new to laravel. if using a middleware is not possible , an event would also be appreciated although i have a lot of routes thereby making the "events" a tedious process. When i log the log the request, i don't get the data i want. how to get the size of the data into kilobytes will also be helpful.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Log;
class MeasureDataSizeMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request);
}
public function terminate($request, $response)
{
// measure the size
//store the data into a database of incoming and outgoing request.
//Log::info('app.requests', ['request' => $request, 'response' => new Response($response)]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire