Files
water_new/app/Http/Middleware/SetServerId.php
2023-03-08 09:16:04 +08:00

30 lines
521 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class SetServerId
{
/**
* 设置响应的 server id便于故障判断
*
* @Author <Jason.C>
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$response->headers->add([
'X-Server-Id' => env('SERVER_ID'),
]);
return $response;
}
}