public function handleRequest($httpContext) { $doneTrigger = new tink_core_FutureTrigger(); if (ufront_remoting_RemotingHandler_0($this, $doneTrigger, $httpContext)) { $r = $httpContext->response; $remotingResponse = null; $r->setOk(); $path = null; $args = null; try { $this->initializeContext($httpContext->injector); $params = $httpContext->request->get_params(); if (!$params->exists("__x")) { throw new HException("Remoting call did not have parameter `__x` which describes which API call to make. Aborting"); } $remotingCall = null; $s = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "__x"); $remotingCall = urldecode($s); $u = new haxe_Unserializer($remotingCall); $path = $u->unserialize(); $args = $u->unserialize(); $apiCallFinished = $this->executeApiCall($path, $args, $this->context, $httpContext->actionContext); $remotingResponse = tink_core__Future_Future_Impl_::map($apiCallFinished, array(new _hx_lambda(array(&$apiCallFinished, &$args, &$doneTrigger, &$httpContext, &$params, &$path, &$r, &$remotingCall, &$remotingResponse, &$u), "ufront_remoting_RemotingHandler_1"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e = $_ex_; $error = $e; $apiNotFoundMessages = new _hx_array(array("Invalid path", "No such object", "Can't access", "No such method")); if ($path !== null && $args !== null && Std::is($e, _hx_qtype("String")) && Lambda::exists($apiNotFoundMessages, array(new _hx_lambda(array(&$apiNotFoundMessages, &$args, &$doneTrigger, &$e, &$error, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_2"), 'execute'))) { $remotingResponse = tink_core__Future_Future_Impl_::sync("Unable to access " . _hx_string_or_null($path->join(".")) . " - API Not Found (" . _hx_string_or_null($error) . "). See " . Std::string($this->context->objects)); $r->setNotFound(); } else { $r->setInternalError(); $remotingResponse = tink_core__Future_Future_Impl_::sync($this->remotingError($e, $httpContext)); } } $remotingResponse(array(new _hx_lambda(array(&$args, &$doneTrigger, &$e, &$httpContext, &$path, &$r, &$remotingResponse), "ufront_remoting_RemotingHandler_3"), 'execute')); } else { $result1 = tink_core_Outcome::Success(tink_core_Noise::$Noise); if ($doneTrigger->{"list"} === null) { false; } else { $list1 = $doneTrigger->{"list"}; $doneTrigger->{"list"} = null; $doneTrigger->result = $result1; tink_core__Callback_CallbackList_Impl_::invoke($list1, $result1); tink_core__Callback_CallbackList_Impl_::clear($list1); true; } } return $doneTrigger->future; }
public function dispose() { $_g = $this; $futures = new _hx_array(array()); $_g1 = 0; $_g11 = $this->getModulesThatRequireInit(); while ($_g1 < $_g11->length) { $module = $_g11[$_g1]; ++$_g1; $futures->push($module->dispose($this)); unset($module); } return tink_core__Future_Future_Impl_::map(tink_core__Future_Future_Impl_::ofMany($futures, null), array(new _hx_lambda(array(&$_g, &$futures), "ufront_app_HttpApplication_2"), 'execute'), null); }
public function requestIn($ctx) { $_g = $this; if (strtolower($ctx->request->get_httpMethod()) === "post" && $ctx->request->isMultipart()) { $file = null; $postName = null; $origFileName = null; $size = 0; $tmpFilePath = null; $dateStr = DateTools::format(Date::now(), "%Y%m%d-%H%M"); $dir = _hx_string_or_null($ctx->get_contentDirectory()) . _hx_string_or_null(haxe_io_Path::addTrailingSlash(ufront_web_upload_TmpFileUploadMiddleware::$subDir)); $path = haxe_io_Path::removeTrailingSlashes($dir); $path1 = haxe_io_Path::addTrailingSlash($path); $_p = null; $parts = new _hx_array(array()); while ($path1 !== ($_p = haxe_io_Path::directory($path1))) { $parts->unshift($path1); $path1 = $_p; } $_g1 = 0; while ($_g1 < $parts->length) { $part = $parts[$_g1]; ++$_g1; if (_hx_char_code_at($part, strlen($part) - 1) !== 58 && !file_exists($part)) { @mkdir($part, 493); } unset($part); } $onPart = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_0"), 'execute'); $onData = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_1"), 'execute'); $onEndPart = array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_2"), 'execute'); return tink_core__Future_Future_Impl_::map($ctx->request->parseMultipart($onPart, $onData, $onEndPart), array(new _hx_lambda(array(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onEndPart, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath), "ufront_web_upload_TmpFileUploadMiddleware_3"), 'execute'), null); } else { return ufront_core_SurpriseTools::success(); } }
public function wrapResultOrError($surprise) { return tink_core__Future_Future_Impl_::map($surprise, array(new _hx_lambda(array(&$surprise), "ufront_web_Controller_1"), 'execute'), null); }
public function _makeApiCall($method, $args, $flags, $pos = null) { if (!php_Boot::$skip_constructor) { $_g = $this; $remotingCallString = "" . _hx_string_or_null($this->className) . "." . _hx_string_or_null($method) . "(" . _hx_string_or_null($args->join(",")) . ")"; $callApi = array(new _hx_lambda(array(&$_g, &$args, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_0"), 'execute'); $returnError = array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString), "ufront_api_UFAsyncApi_1"), 'execute'); if (($flags & 1 << ufront_api_ApiReturnType::$ARTVoid->index) !== 0) { try { call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success(null)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e1 = $_ex_; return call_user_func_array($returnError, array($e1)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0 && ($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $surprise = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($surprise, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$method, &$pos, &$remotingCallString, &$returnError, &$surprise), "ufront_api_UFAsyncApi_2"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e2 = $_ex_; return call_user_func_array($returnError, array($e2)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTFuture->index) !== 0) { try { $future = call_user_func($callApi); return tink_core__Future_Future_Impl_::map($future, array(new _hx_lambda(array(&$_g, &$args, &$callApi, &$flags, &$future, &$method, &$pos, &$remotingCallString, &$returnError), "ufront_api_UFAsyncApi_3"), 'execute'), null); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e3 = $_ex_; return call_user_func_array($returnError, array($e3)); } } else { if (($flags & 1 << ufront_api_ApiReturnType::$ARTOutcome->index) !== 0) { try { $outcome = call_user_func($callApi); switch ($outcome->index) { case 0: $data2 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($data2)); break; case 1: $err1 = _hx_deref($outcome)->params[0]; return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Failure(ufront_web_HttpError::remotingError(ufront_remoting_RemotingError::RApiFailure($remotingCallString, $err1), $pos))); break; } } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e4 = $_ex_; return call_user_func_array($returnError, array($e4)); } } else { try { $result1 = call_user_func($callApi); return tink_core__Future_Future_Impl_::sync(tink_core_Outcome::Success($result1)); } catch (Exception $__hx__e) { $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e; $e5 = $_ex_; return call_user_func_array($returnError, array($e5)); } } } } } } }
static function useFallback($s, $fallback) { return tink_core__Future_Future_Impl_::map($s, array(new _hx_lambda(array(&$fallback, &$s), "ufront_core_SurpriseTools_3"), 'execute'), null); }
static function _map($f, $map) { return tink_core__Future_Future_Impl_::map($f, $map, null); }