<?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;
    }

}
