如果我使用此方法使用此reour http://localhost/esi3d/
它可以正常工作
$app->get(
"/", function () use($app){
$db = new Db_handler;
$result = $db->select_all("clase");
while($row = $result->fetch_assoc()){
$dependency[] = $row ;
}
$struct = array("Dependencies"=>$dependency);
$app->response->headers->set("Content-type","application/json");
$app->response->status(200);
$app->response->body(json_encode($struct));
}
);
但如果我尝试使用参数,则使用该路由http://localhost/esi3d/clase
会出现404错误以使用此方法
$app->get(
"/:table", function ($table) use($app){
$db = new Db_handler;
$result = $db->select_all($table);
while($row = $result->fetch_assoc()){
$dependency[] = $row ;
}
$struct = array("Dependencies"=>$dependency);
$app->response->headers->set("Content-type","application/json");
$app->response->status(200);
$app->response->body(json_encode($struct));
}
);