Author: Hassan Khan (contact@hassankhan.me)
Inheritance: implements Larabros\Elogram\Http\Middleware\MiddlewareInterface
コード例 #1
0
ファイル: AuthMiddleware.php プロジェクト: larabros/elogram
 /**
  * {@inheritDoc}
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     $next = $this->nextHandler;
     if (!$this->config->has('access_token') || $this->config->get('access_token') === null) {
         return $next($request, $options);
     }
     $uri = Uri::withQueryValue($request->getUri(), 'access_token', $this->config->get('access_token')->getToken());
     return parent::__invoke($request->withUri($uri)->withHeader('Content-Type', 'application/json'), $options);
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     $next = $this->nextHandler;
     if (!$this->config->get('secure_requests')) {
         return $next($request, $options);
     }
     $uri = $request->getUri();
     $sig = $this->generateSig($this->getPath($uri), $this->getQueryParams($uri), $this->config->get('client_secret'));
     $uri = Uri::withQueryValue($uri, 'sig', $sig);
     return parent::__invoke($request->withUri($uri), $options);
 }