PrecognitionCallableDispatcher.php
TLDR
This file contains the PrecognitionCallableDispatcher
class which extends the CallableDispatcher
class. It overrides the dispatch
method to resolve parameters and then aborts with a 204 status code and a custom header.
Classes
PrecognitionCallableDispatcher
The PrecognitionCallableDispatcher
class extends the CallableDispatcher
class. It provides a method named dispatch
which takes in a Route
object and a callable as parameters. Inside the method, it calls the resolveParameters
method to resolve the parameters for the route and callable. Then it aborts with a 204 status code and sets a custom header "Precognition-Success" to "true".
<?php
namespace Illuminate\Foundation\Routing;
use Illuminate\Routing\CallableDispatcher;
use Illuminate\Routing\Route;
class PrecognitionCallableDispatcher extends CallableDispatcher
{
/**
* Dispatch a request to a given callable.
*
* @param \Illuminate\Routing\Route $route
* @param callable $callable
* @return mixed
*/
public function dispatch(Route $route, $callable)
{
$this->resolveParameters($route, $callable);
abort(204, headers: ['Precognition-Success' => 'true']);
}
}