feat(infrastructure): Enhance router and API endpoint with proper error handling

This commit is contained in:
m.jalmoudy
2025-12-02 15:00:35 +03:30
parent 6b5222ad84
commit 5326f40b2b
3 changed files with 24 additions and 84 deletions

View File

@@ -19,11 +19,12 @@ class Router
{
foreach ($this->routes as $route) {
if ($route['method'] === $method && $route['path'] === $uri) {
return call_user_func($route['handler']);
return \call_user_func($route['handler']);
}
}
http_response_code(404);
echo "Not Found";
header('Content-Type: application/json');
echo json_encode(['error' => 'Not Found']);
}
}