Skip to content

Commit

Permalink
Laravel - cache incoming request instance before middleware is applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
itsgoingd committed Mar 13, 2021
1 parent 5d8b27d commit cb17e34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Clockwork/Support/Laravel/ClockworkSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class ClockworkSupport
// Laravel application instance
protected $app;

// Incoming request instance
protected $incomingRequest;

public function __construct(Application $app)
{
$this->app = $app;
Expand Down Expand Up @@ -627,7 +630,9 @@ protected function appendServerTimingHeader($response, $request)
// Make an incoming request instance
protected function incomingRequest()
{
return new IncomingRequest([
if ($this->incomingRequest) return $this->incomingRequest;

return $this->incomingRequest = new IncomingRequest([
'method' => $this->app['request']->getMethod(),
'uri' => $this->app['request']->getRequestUri(),
'input' => $this->app['request']->input(),
Expand Down

0 comments on commit cb17e34

Please sign in to comment.