Update for new application bootstrap, default redirect handling was added

This commit is contained in:
Erik Amaru Ortiz
2014-03-13 10:23:50 -04:00
parent b4d32fcb58
commit b6a7122bb7
2 changed files with 24 additions and 2 deletions

View File

@@ -9,10 +9,13 @@ class WebApplication
protected $workflowDir = ""; protected $workflowDir = "";
protected $requestUri = ""; protected $requestUri = "";
const RUNNING_DEFAULT = "default.running";
const RUNNING_INDEX = "index.running";
const RUNNING_WORKFLOW = "workflow.running"; const RUNNING_WORKFLOW = "workflow.running";
const RUNNING_API = "api.running"; const RUNNING_API = "api.running";
const SERVICE_API = "service.api";
const SERVICE_API = "service.api";
const REDIRECT_DEFAULT = "redirect.default";
public function __construct() public function __construct()
{ {
@@ -54,7 +57,13 @@ class WebApplication
public function route() public function route()
{ {
if (substr($this->requestUri, 1, 3) == "api") { if ($this->requestUri === "/") {
if (file_exists("index.html")) {
return self::RUNNING_INDEX;
} else {
return self::RUNNING_DEFAULT;
}
} elseif (substr($this->requestUri, 1, 3) === "api") {
return self::RUNNING_API; return self::RUNNING_API;
} else { } else {
return self::RUNNING_WORKFLOW; return self::RUNNING_WORKFLOW;
@@ -64,6 +73,10 @@ class WebApplication
public function run($type = "") public function run($type = "")
{ {
switch ($type) { switch ($type) {
case self::REDIRECT_DEFAULT:
//TODO we can set a configurable redirect url
header("location: /sys/en/neoclassic/login/login");
break;
case self::SERVICE_API: case self::SERVICE_API:
$request = $this->parseApiRequestUri(); $request = $this->parseApiRequestUri();
$this->loadEnvironment($request["workspace"]); $this->loadEnvironment($request["workspace"]);

View File

@@ -57,6 +57,15 @@ try {
case Maveriks\WebApplication::RUNNING_API: case Maveriks\WebApplication::RUNNING_API:
$app->run(Maveriks\WebApplication::SERVICE_API); $app->run(Maveriks\WebApplication::SERVICE_API);
break; break;
case Maveriks\WebApplication::RUNNING_INDEX:
$response = new Maveriks\Http\Response(file_get_contents("index.html"), 302);
$response->send();
break;
case Maveriks\WebApplication::RUNNING_DEFAULT:
$app->run(Maveriks\WebApplication::REDIRECT_DEFAULT);
break;
} }
} catch (Exception $e) { } catch (Exception $e) {