path(); echo "[INFO]", date('h:i:s'), " request {$path} \n"; if (isset(self::$Routes[$path])) { try{ $handler = self::$Routes[$path]; if(!isset(self::$Instance[$handler])){ echo "[INFO]", date('H:i:s'), " initial instance of {$handler}\n"; self::$Instance[$handler] = new $handler(); } if (self::$Instance[$handler] instanceof Api) { $result = self::$Instance[$handler]->handle($request); if($result instanceof Response){ return $result; } return new Response(200, [], $result); } }catch (\Exception $e){ return new Response(500, [], $e->getMessage()); } // print_r($handler); } return new Response(200, [], '404'); } }