if ($summary !== null) {
$message .= ":\n{$summary}\n";
}
return new $className($message, $request, $response, $previous, $handlerContext);
}
/**
* Obfuscates URI if there is a username and a password present
*/
static function (ResponseInterface $response) use ($request, $bodySummarizer) {
$code = $response->getStatusCode();
if ($code < 400) {
return $response;
}
throw RequestException::create($request, $response, null, [], $bodySummarizer);
}
);
};
};
}
* itself we get a circular reference. We clear the $handler
* here to avoid that memory leak.
*/
$f = $handler[$index];
unset($handler);
$promise->resolve($f($value));
} elseif ($index === 1) {
// Forward resolution values as-is.
$promise->resolve($value);
} else {
// Forward rejections down the chain.
if (!is_object($value) || !method_exists($value, 'then')) {
$id = $state === self::FULFILLED ? 1 : 2;
// It's a success, so resolve the handlers in the queue.
Utils::queue()->add(static function () use ($id, $value, $handlers) {
foreach ($handlers as $handler) {
self::callHandler($id, $value, $handler);
}
});
} elseif ($value instanceof Promise && Is::pending($value)) {
// We can just merge our handlers onto the next promise.
$value->handlers = array_merge($value->handlers, $handlers);
public function run()
{
while ($task = array_shift($this->queue)) {
/** @var callable $task */
$task();
}
}
/**
* The task queue will be run and exhausted by default when the process
private function invokeWaitFn()
{
try {
$wfn = $this->waitFn;
$this->waitFn = null;
$wfn(true);
} catch (\Exception $reason) {
if ($this->state === self::PENDING) {
// The promise has not been resolved yet, so reject the promise
// with the exception.
$this->reject($reason);
private function waitIfPending()
{
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
$waitList = $this->waitList;
$this->waitList = null;
foreach ($waitList as $result) {
do {
$result->waitIfPending();
$result = $result->result;
} while ($result instanceof Promise);
if ($result instanceof PromiseInterface) {
$result->wait(false);
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
. 'no internal wait function. You must provide a wait '
. 'function when constructing the promise to be able to '
return $this->then(null, $onRejected);
}
public function wait($unwrap = true)
{
$this->waitIfPending();
if ($this->result instanceof PromiseInterface) {
return $this->result->wait($unwrap);
}
if ($unwrap) {
* @throws GuzzleException
*/
public function request(string $method, $uri = '', array $options = []): ResponseInterface
{
$options[RequestOptions::SYNCHRONOUS] = true;
return $this->requestAsync($method, $uri, $options)->wait();
}
/**
* Get a client configuration option.
*
'Content-Type' => 'application/json'
]
]);
$reponse = $client->request($req, $url, [
'form_params' => $body,
'connect_timeout' => $timeout,
]);
$result = $reponse->getBody()->getContents();
return $result;
}
protected function cardapios($cnpj, $id_cardapio)
{
$url = env('URL_VIAPP') . 'empresa-v2/cardapios/' . $cnpj . '/' . $id_cardapio . '/normal';
$dados = GuzzleHelper::makeRequestWithBearer('GET', $url, null, $this->token);
if ($dados) {
return json_decode($dados, true);
}
}
$dados_viapp = ($request->session()->get('dados_viapp'));
$empresa = Empresa::where('cnpj', $cnpj)->first();
$cardapios = $this->cardapios($cnpj, $catalogo);
if(isset($dados_viapp)){
$dados_viapp['cardapios'] = $cardapios;
}else{
$dados_viapp = array();
$dados_viapp['cardapios'] = $cardapios;
if (static::isCallableWithAtSign($callback) || $defaultMethod) {
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return $callback(...array_values(static::getMethodDependencies($container, $callback, $parameters)));
});
}
/**
* Call a string reference to a class using Class@method syntax.
* @param mixed $value
* @return mixed
*/
public static function unwrapIfClosure($value)
{
return $value instanceof Closure ? $value() : $value;
}
/**
* Get the class name of the given parameter's type, if possible.
*
if ($container->hasMethodBinding($method)) {
return $container->callMethodBinding($method, $callback[0]);
}
return Util::unwrapIfClosure($default);
}
/**
* Normalize the given callback into a Class@method string.
*
return static::callClass($container, $callback, $parameters, $defaultMethod);
}
return static::callBoundMethod($container, $callback, function () use ($container, $callback, $parameters) {
return $callback(...array_values(static::getMethodDependencies($container, $callback, $parameters)));
});
}
/**
* Call a string reference to a class using Class@method syntax.
*
*
* @throws \InvalidArgumentException
*/
public function call($callback, array $parameters = [], $defaultMethod = null)
{
return BoundMethod::call($this, $callback, $parameters, $defaultMethod);
}
/**
* Get a closure to resolve the given type from the container.
*
*/
protected function callControllerCallable(callable $callable, array $parameters = [])
{
try {
return $this->prepareResponse(
$this->call($callable, $parameters)
);
} catch (HttpResponseException $e) {
return $e->getResponse();
}
}
return $this->callLumenControllerWithMiddleware(
$instance, $method, $routeInfo, $middleware
);
} else {
return $this->callControllerCallable(
[$instance, $method], $routeInfo[2]
);
}
}
/**
if (! method_exists($instance = $this->make($controller), $method)) {
throw new NotFoundHttpException;
}
if ($instance instanceof LumenController) {
return $this->callLumenController($instance, $method, $routeInfo);
} else {
return $this->callControllerCallable(
[$instance, $method], $routeInfo[2]
);
}
protected function callActionOnArrayBasedRoute($routeInfo)
{
$action = $routeInfo[1];
if (isset($action['uses'])) {
return $this->prepareResponse($this->callControllerAction($routeInfo));
}
foreach ($action as $value) {
if ($value instanceof Closure) {
$callable = $value->bindTo(new RoutingClosure);
return $this->callActionOnArrayBasedRoute($this['request']->route());
}));
}
return $this->prepareResponse(
$this->callActionOnArrayBasedRoute($routeInfo)
);
}
/**
* Call the Closure or invokable on the array based route.
case Dispatcher::NOT_FOUND:
throw new NotFoundHttpException;
case Dispatcher::METHOD_NOT_ALLOWED:
throw new MethodNotAllowedHttpException($routeInfo[1]);
case Dispatcher::FOUND:
return $this->handleFoundRoute($routeInfo);
}
}
/**
* Handle a route found by the dispatcher.
if (isset($this->router->getRoutes()[$method.$pathInfo])) {
return $this->handleFoundRoute([true, $this->router->getRoutes()[$method.$pathInfo]['action'], []]);
}
return $this->handleDispatcherResponse(
$this->createDispatcher()->dispatch($method, $pathInfo)
);
});
} catch (Throwable $e) {
return $this->prepareResponse($this->sendExceptionToHandler($e));
}
*/
protected function prepareDestination(BaseClosure $destination)
{
return function ($passable) use ($destination) {
try {
return $destination($passable);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
}
};
}
$this->startSession($request, $session)
);
$this->collectGarbage($session);
$response = $next($request);
$this->storeCurrentUrl($request, $session);
$this->addCookieToResponse($response, $session);
if ($this->manager->shouldBlock() ||
($request->route() instanceof Route && $request->route()->locksFor())) {
return $this->handleRequestWhileBlocking($request, $session, $next);
}
return $this->handleStatefulRequest($request, $session, $next);
}
/**
* Handle the given request within session state.
*
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
return function ($stack, $pipe) {
return function ($passable) use ($stack, $pipe) {
try {
$slice = parent::carry();
return ($slice($stack, $pipe))($passable);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
}
};
};
{
$pipeline = array_reduce(
array_reverse($this->pipes()), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
}
/**
* Run the pipeline and return the result.
*
{
if (count($middleware) > 0 && ! $this->shouldSkipMiddleware()) {
return (new Pipeline($this))
->send($this->make('request'))
->through($middleware)
->then($then);
}
return $then($this->make('request'));
}
}
return $this->handleDispatcherResponse(
$this->createDispatcher()->dispatch($method, $pathInfo)
);
});
} catch (Throwable $e) {
return $this->prepareResponse($this->sendExceptionToHandler($e));
}
}
* @param \Symfony\Component\HttpFoundation\Request|null $request
* @return void
*/
public function run($request = null)
{
$response = $this->dispatch($request);
if ($response instanceof SymfonyResponse) {
$response->send();
} else {
echo (string) $response;
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();
ClientException
|
---|
GuzzleHttp\Exception\ClientException: Client error: `GET https://api.viapp.com.br/empresa-v2/cardapios/25181030000172/185/normal` resulted in a `404 Not Found` response: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="robots" content="noindex,nofollow,noarchive" (truncated...) at /app/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 at GuzzleHttp\Exception\RequestException::create() (/app/vendor/guzzlehttp/guzzle/src/Middleware.php:69) at GuzzleHttp\Middleware::GuzzleHttp\{closure}() (/app/vendor/guzzlehttp/promises/src/Promise.php:204) at GuzzleHttp\Promise\Promise::callHandler() (/app/vendor/guzzlehttp/promises/src/Promise.php:153) at GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (/app/vendor/guzzlehttp/promises/src/TaskQueue.php:48) at GuzzleHttp\Promise\TaskQueue->run() (/app/vendor/guzzlehttp/promises/src/Promise.php:248) at GuzzleHttp\Promise\Promise->invokeWaitFn() (/app/vendor/guzzlehttp/promises/src/Promise.php:224) at GuzzleHttp\Promise\Promise->waitIfPending() (/app/vendor/guzzlehttp/promises/src/Promise.php:269) at GuzzleHttp\Promise\Promise->invokeWaitList() (/app/vendor/guzzlehttp/promises/src/Promise.php:226) at GuzzleHttp\Promise\Promise->waitIfPending() (/app/vendor/guzzlehttp/promises/src/Promise.php:62) at GuzzleHttp\Promise\Promise->wait() (/app/vendor/guzzlehttp/guzzle/src/Client.php:187) at GuzzleHttp\Client->request() (/app/app/Helpers/GuzzleHelper.php:46) at App\Helpers\GuzzleHelper::makeRequestWithBearer() (/app/app/Http/Controllers/EmpresaController.php:100) at App\Http\Controllers\EmpresaController->cardapios() (/app/app/Http/Controllers/EmpresaController.php:184) at App\Http\Controllers\EmpresaController->indexCardapio() (/app/vendor/illuminate/container/BoundMethod.php:36) at Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() (/app/vendor/illuminate/container/Util.php:40) at Illuminate\Container\Util::unwrapIfClosure() (/app/vendor/illuminate/container/BoundMethod.php:93) at Illuminate\Container\BoundMethod::callBoundMethod() (/app/vendor/illuminate/container/BoundMethod.php:37) at Illuminate\Container\BoundMethod::call() (/app/vendor/illuminate/container/Container.php:653) at Illuminate\Container\Container->call() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:389) at Laravel\Lumen\Application->callControllerCallable() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:355) at Laravel\Lumen\Application->callLumenController() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:329) at Laravel\Lumen\Application->callControllerAction() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:282) at Laravel\Lumen\Application->callActionOnArrayBasedRoute() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:267) at Laravel\Lumen\Application->handleFoundRoute() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:237) at Laravel\Lumen\Application->handleDispatcherResponse() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:173) at Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}() (/app/vendor/laravel/lumen-framework/src/Routing/Pipeline.php:48) at Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing\{closure}() (/app/vendor/illuminate/session/Middleware/StartSession.php:121) at Illuminate\Session\Middleware\StartSession->handleStatefulRequest() (/app/vendor/illuminate/session/Middleware/StartSession.php:64) at Illuminate\Session\Middleware\StartSession->handle() (/app/vendor/illuminate/pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/app/vendor/laravel/lumen-framework/src/Routing/Pipeline.php:30) at Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing\{closure}() (/app/vendor/illuminate/pipeline/Pipeline.php:103) at Illuminate\Pipeline\Pipeline->then() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:426) at Laravel\Lumen\Application->sendThroughPipeline() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:175) at Laravel\Lumen\Application->dispatch() (/app/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:112) at Laravel\Lumen\Application->run() (/app/public/index.php:28) |