Useful middleware for Laravel Requests & Jobs to determine which server is serving (or running) the request. For HTTP requests, the identifier string will be sent back as HTTP Header "X-Served-By". In jobs, it is possible to send Context to Flare, or tag the server in Horizon.
You can install the package via composer:
composer require creativeorange/laravel-served-by
For Laravel 8 or lower please install version 1.
To allow Served By for all your routes, add the ServedBy middleware at the top of the $middleware property of app/Http/Kernel.php class:
protected $middleware = [
\Creativeorange\ServedBy\Http\Middleware\ServedBy::class,
// ...
];
If you use Flare, you can add the following to your job(s):
/**
* Get the middleware the job should pass through.
*
* @return array
*/
public function middleware()
{
return [new Creativeorange\ServedBy\Http\Middleware\Jobs\ServedBy];
}
The defaults are set in config/served-by.php. Publish the config to copy the file to your own config:
php artisan vendor:publish --tag="served-by"
By default, you can also overwrite the identifier string by adding SERVED_BY_IDENTIFIER
to your .env
The MIT License (MIT). Please see License File for more information.