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;
 }
 static function combine($maps)
 {
     $qm = new haxe_ds_StringMap();
     $_g = 0;
     while ($_g < $maps->length) {
         $map = $maps[$_g];
         ++$_g;
         if (null == $map) {
             throw new HException('null iterable');
         }
         $__hx__it = $map->keys();
         while ($__hx__it->hasNext()) {
             unset($key);
             $key = $__hx__it->next();
             $_g1 = 0;
             $_g2 = ufront_core__MultiValueMap_MultiValueMap_Impl_::getAll($map, $key);
             while ($_g1 < $_g2->length) {
                 $val = $_g2[$_g1];
                 ++$_g1;
                 ufront_core__MultiValueMap_MultiValueMap_Impl_::add($qm, $key, $val);
                 unset($val);
             }
             unset($_g2, $_g1);
         }
         unset($map);
     }
     return $qm;
 }
 static function getMultiValueMapFromString($s)
 {
     $map = new haxe_ds_StringMap();
     $_g = 0;
     $_g1 = _hx_explode("&", $s);
     while ($_g < $_g1->length) {
         $part = $_g1[$_g];
         ++$_g;
         $index = _hx_index_of($part, "=", null);
         if ($index > 0) {
             $name = _hx_substr($part, 0, $index);
             $val = _hx_substr($part, $index + 1, null);
             ufront_core__MultiValueMap_MultiValueMap_Impl_::add($map, $name, $val);
             unset($val, $name);
         }
         unset($part, $index);
     }
     return $map;
 }
 public function get_id()
 {
     if ($this->sessionID === null) {
         $this->sessionID = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($this->context->request->get_cookies(), $this->sessionName);
     }
     if ($this->sessionID === null) {
         $this->sessionID = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($this->context->request->get_params(), $this->sessionName);
     }
     return $this->sessionID;
 }
 public function execute()
 {
     $uriParts = $this->context->actionContext->get_uriParts();
     $this->setBaseUri($uriParts);
     $params = $this->context->request->get_params();
     $method = $this->context->request->get_httpMethod();
     $this->context->actionContext->controller = $this;
     $this->context->actionContext->action = "execute";
     try {
         if (0 === $uriParts->length) {
             $this->context->actionContext->action = "index";
             $this->context->actionContext->args = new _hx_array(array());
             $this->context->actionContext->get_uriParts()->splice(0, 0);
             $wrappingRequired = null;
             $i = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->index->wrapResult[0];
             $wrappingRequired = $i;
             $result = $this->wrapResult($this->index(), $wrappingRequired);
             $this->setContextActionResultWhenFinished($result);
             return $result;
         } else {
             if (1 === $uriParts->length && $uriParts[0] === "querystring") {
                 $this->context->actionContext->action = "queryString";
                 $this->context->actionContext->args = new _hx_array(array());
                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                 $wrappingRequired1 = null;
                 $i1 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->queryString->wrapResult[0];
                 $wrappingRequired1 = $i1;
                 $result1 = $this->wrapResult($this->queryString(), $wrappingRequired1);
                 $this->setContextActionResultWhenFinished($result1);
                 return $result1;
             } else {
                 if (1 === $uriParts->length && $uriParts[0] === "poststring") {
                     $this->context->actionContext->action = "postString";
                     $this->context->actionContext->args = new _hx_array(array());
                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                     $wrappingRequired2 = null;
                     $i2 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->postString->wrapResult[0];
                     $wrappingRequired2 = $i2;
                     $result2 = $this->wrapResult($this->postString(), $wrappingRequired2);
                     $this->setContextActionResultWhenFinished($result2);
                     return $result2;
                 } else {
                     if (1 === $uriParts->length && $uriParts[0] === "query") {
                         $this->context->actionContext->action = "query";
                         $this->context->actionContext->args = new _hx_array(array());
                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                         $wrappingRequired3 = null;
                         $i3 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->query->wrapResult[0];
                         $wrappingRequired3 = $i3;
                         $result3 = $this->wrapResult($this->query(), $wrappingRequired3);
                         $this->setContextActionResultWhenFinished($result3);
                         return $result3;
                     } else {
                         if (1 === $uriParts->length && $uriParts[0] === "post") {
                             $this->context->actionContext->action = "post";
                             $this->context->actionContext->args = new _hx_array(array());
                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                             $wrappingRequired4 = null;
                             $i4 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->post->wrapResult[0];
                             $wrappingRequired4 = $i4;
                             $result4 = $this->wrapResult($this->post(), $wrappingRequired4);
                             $this->setContextActionResultWhenFinished($result4);
                             return $result4;
                         } else {
                             if (1 === $uriParts->length && $uriParts[0] === "cookies") {
                                 $this->context->actionContext->action = "cookies";
                                 $this->context->actionContext->args = new _hx_array(array());
                                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                                 $wrappingRequired5 = null;
                                 $i5 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->cookies->wrapResult[0];
                                 $wrappingRequired5 = $i5;
                                 $result5 = $this->wrapResult($this->cookies(), $wrappingRequired5);
                                 $this->setContextActionResultWhenFinished($result5);
                                 return $result5;
                             } else {
                                 if (1 === $uriParts->length && $uriParts[0] === "clientheaders") {
                                     $this->context->actionContext->action = "clientHeaders";
                                     $this->context->actionContext->args = new _hx_array(array());
                                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                                     $wrappingRequired6 = null;
                                     $i6 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->clientHeaders->wrapResult[0];
                                     $wrappingRequired6 = $i6;
                                     $result6 = $this->wrapResult($this->clientHeaders(), $wrappingRequired6);
                                     $this->setContextActionResultWhenFinished($result6);
                                     return $result6;
                                 } else {
                                     if (1 === $uriParts->length && $uriParts[0] === "hostname") {
                                         $this->context->actionContext->action = "hostname";
                                         $this->context->actionContext->args = new _hx_array(array());
                                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                                         $wrappingRequired7 = null;
                                         $i7 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->hostname->wrapResult[0];
                                         $wrappingRequired7 = $i7;
                                         $result7 = $this->wrapResult($this->hostname(), $wrappingRequired7);
                                         $this->setContextActionResultWhenFinished($result7);
                                         return $result7;
                                     } else {
                                         if (1 === $uriParts->length && $uriParts[0] === "clientip") {
                                             $this->context->actionContext->action = "clientIP";
                                             $this->context->actionContext->args = new _hx_array(array());
                                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                                             $wrappingRequired8 = null;
                                             $i8 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->clientIP->wrapResult[0];
                                             $wrappingRequired8 = $i8;
                                             $result8 = $this->wrapResult($this->clientIP(), $wrappingRequired8);
                                             $this->setContextActionResultWhenFinished($result8);
                                             return $result8;
                                         } else {
                                             if (1 <= $uriParts->length && $uriParts[0] === "uri") {
                                                 $this->context->actionContext->action = "uri";
                                                 $this->context->actionContext->args = new _hx_array(array());
                                                 $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                 $wrappingRequired9 = null;
                                                 $i9 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->uri->wrapResult[0];
                                                 $wrappingRequired9 = $i9;
                                                 $result9 = $this->wrapResult($this->uri(), $wrappingRequired9);
                                                 $this->setContextActionResultWhenFinished($result9);
                                                 return $result9;
                                             } else {
                                                 if (1 === $uriParts->length && $uriParts[0] === "httpmethod") {
                                                     $this->context->actionContext->action = "httpMethod";
                                                     $this->context->actionContext->args = new _hx_array(array());
                                                     $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                     $wrappingRequired10 = null;
                                                     $i10 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->httpMethod->wrapResult[0];
                                                     $wrappingRequired10 = $i10;
                                                     $result10 = $this->wrapResult($this->httpMethod(), $wrappingRequired10);
                                                     $this->setContextActionResultWhenFinished($result10);
                                                     return $result10;
                                                 } else {
                                                     if (1 === $uriParts->length && $uriParts[0] === "scriptdirectory") {
                                                         $this->context->actionContext->action = "scriptDir";
                                                         $this->context->actionContext->args = new _hx_array(array());
                                                         $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                         $wrappingRequired11 = null;
                                                         $i11 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->scriptDir->wrapResult[0];
                                                         $wrappingRequired11 = $i11;
                                                         $result11 = $this->wrapResult($this->scriptDir(), $wrappingRequired11);
                                                         $this->setContextActionResultWhenFinished($result11);
                                                         return $result11;
                                                     } else {
                                                         if (1 === $uriParts->length && $uriParts[0] === "authorization") {
                                                             $this->context->actionContext->action = "authorization";
                                                             $this->context->actionContext->args = new _hx_array(array());
                                                             $this->context->actionContext->get_uriParts()->splice(0, 1);
                                                             $wrappingRequired12 = null;
                                                             $i12 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->authorization->wrapResult[0];
                                                             $wrappingRequired12 = $i12;
                                                             $result12 = $this->wrapResult($this->authorization(), $wrappingRequired12);
                                                             $this->setContextActionResultWhenFinished($result12);
                                                             return $result12;
                                                         } else {
                                                             if (3 === $uriParts->length && $uriParts[0] === "testresponse" && strlen($uriParts[1]) > 0 && strlen($uriParts[2]) > 0) {
                                                                 $status = Std::parseInt($uriParts[1]);
                                                                 if ($status === null) {
                                                                     throw new HException(testsite_Routes_0($this, $method, $params, $status, $uriParts));
                                                                 }
                                                                 $charset = $uriParts[2];
                                                                 $_param_tmp_language = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "language");
                                                                 $_param_tmp_contentType = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "contentType");
                                                                 $_param_tmp_content = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "content");
                                                                 $_param_tmp_cookieName = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "cookieName");
                                                                 $_param_tmp_cookieVal = ufront_core__MultiValueMap_MultiValueMap_Impl_::get($params, "cookieVal");
                                                                 $args = _hx_anonymous(array("language" => $_param_tmp_language, "contentType" => $_param_tmp_contentType, "content" => $_param_tmp_content, "cookieName" => $_param_tmp_cookieName, "cookieVal" => $_param_tmp_cookieVal));
                                                                 $this->context->actionContext->action = "testResponse";
                                                                 $this->context->actionContext->args = new _hx_array(array($status, $charset, $args));
                                                                 $this->context->actionContext->get_uriParts()->splice(0, 3);
                                                                 $wrappingRequired13 = null;
                                                                 $i13 = haxe_rtti_Meta::getFields(_hx_qtype("testsite.Routes"))->testResponse->wrapResult[0];
                                                                 $wrappingRequired13 = $i13;
                                                                 $result13 = $this->wrapResult($this->testResponse($status, $charset, $args), $wrappingRequired13);
                                                                 $this->setContextActionResultWhenFinished($result13);
                                                                 return $result13;
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         throw new HException(ufront_web_HttpError::pageNotFound(_hx_anonymous(array("fileName" => "ControllerMacros.hx", "lineNumber" => 442, "className" => "testsite.Routes", "methodName" => "execute"))));
     } catch (Exception $__hx__e) {
         $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
         $e = $_ex_;
         return ufront_core_SurpriseTools::asSurpriseError($e, "Uncaught error while executing " . Std::string($this->context->actionContext->controller) . "." . _hx_string_or_null($this->context->actionContext->action) . "()", _hx_anonymous(array("fileName" => "ControllerMacros.hx", "lineNumber" => 445, "className" => "testsite.Routes", "methodName" => "execute")));
     }
 }
 public function isMultipart()
 {
     return ufront_web_context_HttpRequest_0($this) && StringTools::startsWith(ufront_core__MultiValueMap_MultiValueMap_Impl_::get($this->get_clientHeaders(), "Content-Type"), "multipart/form-data");
 }
function ufront_web_upload_TmpFileUploadMiddleware_2(&$_g, &$ctx, &$dateStr, &$dir, &$file, &$onData, &$onPart, &$origFileName, &$postName, &$size, &$tmpFilePath)
{
    if ($file !== null) {
        $file->close();
        $file = null;
        $tmpFile = new ufront_web_upload_TmpFileUpload($tmpFilePath, $postName, $origFileName, $size);
        ufront_core__MultiValueMap_MultiValueMap_Impl_::add($ctx->request->get_files(), $postName, $tmpFile);
        $_g->files->push($tmpFile);
    }
    return ufront_core_SurpriseTools::success();
}