저자: Hassan Khan (contact@hassankhan.me)
상속: implements Larabros\Elogram\Http\Middleware\MiddlewareInterface
예제 #1
0
 /**
  * {@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);
 }