Created
June 26, 2018 07:53
-
-
Save emir/c121cfc0992e15c6d2afd412f0f4a9be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\JsonResponse; | |
use Illuminate\Support\Facades\Log; | |
class LogRequestResponse | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
Log::info('app.request', ['request' => $request->all(), 'header' => $request->headers->all()]); | |
return $next($request); | |
} | |
/** | |
* @param $request | |
* @param JsonResponse $response | |
*/ | |
public function terminate($request, JsonResponse $response) | |
{ | |
Log::info('app.response', ['response' => $response->getContent(), 'header' => $response->headers->all()]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment