|
@@ -8,6 +8,10 @@
|
8
|
8
|
|
9
|
9
|
namespace Luticate\Utils\Controller;
|
10
|
10
|
|
|
11
|
+use Luticate\Utils\Business\LuBusinessException;
|
|
12
|
+use Luticate\Utils\Business\LuLog;
|
|
13
|
+use Luticate\Utils\Dbo\LuDbo;
|
|
14
|
+use Luticate\Utils\Dbo\LuRequestDbo;
|
11
|
15
|
use Ratchet\ConnectionInterface;
|
12
|
16
|
use Ratchet\MessageComponentInterface;
|
13
|
17
|
use Ratchet\Http\HttpServer;
|
|
@@ -85,8 +89,28 @@ class LuticateApplication implements MessageComponentInterface
|
85
|
89
|
$url = $_SERVER['REQUEST_URI'];
|
86
|
90
|
|
87
|
91
|
$parameters = array_merge($_GET, $_POST);
|
|
92
|
+ $r = new LuRequestDbo();
|
|
93
|
+ $r->setVersion($this->getVersion());
|
88
|
94
|
|
89
|
|
- $this->_router->dispatch($httpMethod, $url, $parameters);
|
|
95
|
+ try {
|
|
96
|
+ $result = $this->_router->dispatch($httpMethod, $url, $parameters);
|
|
97
|
+ $r->setData($result);
|
|
98
|
+ $r->setStatusCode(200);
|
|
99
|
+ }
|
|
100
|
+ catch (LuBusinessException $e)
|
|
101
|
+ {
|
|
102
|
+ LuLog::log($e);
|
|
103
|
+ $r->setStatusCode($e->getCode());
|
|
104
|
+ $r->setMessage($e->getMessage());
|
|
105
|
+ }
|
|
106
|
+ catch (\Exception $e)
|
|
107
|
+ {
|
|
108
|
+ LuLog::log($e);
|
|
109
|
+ $r->setStatusCode(500);
|
|
110
|
+ $r->setMessage("Internal Error");
|
|
111
|
+ }
|
|
112
|
+ http_response_code($r->getStatusCode());
|
|
113
|
+ echo $r->__toString();
|
90
|
114
|
}
|
91
|
115
|
|
92
|
116
|
public function runWs()
|