onHandler($request, $passable); } catch (\Throwable $throwable) { logger()->addError($throwable, 'throwable'); return Json::to(0, $throwable); } }; }); } /** * @return Closure */ private static function core(): Closure { return function ($stack, $pipe) { return static::passable($stack, $pipe); }; } /** * @param $stack * @param $pipe * @return Closure */ public static function passable($stack, $pipe): Closure { return function ($passable) use ($stack, $pipe) { if (!($pipe instanceof Middleware)) { return call_user_func($pipe, $passable, $stack); } else { return $pipe->onHandler($passable, $stack); } }; } }