private function initRouter() { $this->router = new RouteCollector(); $this->router->get('/cmd{id:\\d+}', function ($id) { $controller = new Controller($this); $content = $controller->actionIncrement($id); return $content; }); $this->router->get('/cmd', function () { $controller = new Controller($this); $this->responseContentType = 'application/json'; $content = $controller->actionSummary(); return $content; }); $this->router->post('/cmd{id:\\d+}', function ($id) { $this->request->on('data', function ($data) use($id) { parse_str($data, $data); $controller = new Controller($this); $content = $controller->actionUpdate($id, $data); return $content; }); }); }