1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use App\Exceptions\ApiException;
- class BindToken
- {
- use CheckTokenTrait;
- /**
- * @param $request
- * @param Closure $next
- * @return mixed
- * @throws ApiException
- */
- public function handle($request, Closure $next)
- {
- // 接口中的token(如有则绑定token到全局)
- $token = $request->header('d-token', '');
- $channelId = (int)$request->header('d-channel-id', 0);
- if ($token && $channelId) {
- $this->checkTokenTrait($token, $channelId);
- }
- return $next($request);
- }
- }
|