Laravel middleware to add PR message to API response headers.
You can enter the message you want to convey to the user!
Install using Composer:
composer require naotty/laravel-pr-messageRun the following command to publish the configuration file:
php artisan vendor:publish --tag=pr-message-configThis will create the config/pr-message.php file.
Edit the config/pr-message.php file to customize the PR messages:
return [
'messages' => [
'Would you like to work with us? We are hiring engineers!',
'This service makes you happy!',
'Let\'s create better services together!',
'This service makes your life better!',
'You, who are reading this message, would you like to work with us?',
// Add your own messages
],
];When using this middleware, the following HTTP header will be added to your API responses:
pr-message: A randomly selected message from your configured message list
Add the following to the $middleware array in the app/Http/Kernel.php file:
protected $middleware = [
// Other middleware
\Naotty\LaravelPrMessage\Middleware\AddPrMessageHeader::class,
];Use the alias that is already registered in the $routeMiddleware array in the app/Http/Kernel.php file:
protected $routeMiddleware = [
// Other middleware
'pr-message' => \Naotty\LaravelPrMessage\Middleware\AddPrMessageHeader::class,
];Then, use it in the route definition:
Route::get('/api/endpoint', function () {
return response()->json(['data' => 'example']);
})->middleware('pr-message');MIT