diff --git a/README.md b/README.md index 4b64da1..c860957 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ Todos: - [ ] Collect routes properly - [ ] Process routes correctly +- [ ] Add request and response objects diff --git a/app/Controller/BaseController.php b/app/Controller/BaseController.php index aa0a79b..7df9387 100644 --- a/app/Controller/BaseController.php +++ b/app/Controller/BaseController.php @@ -3,12 +3,14 @@ namespace App\Controller; use Ardent\Undercurrent\Attribute\Route; +use Ardent\Undercurrent\Http\GenericResponse; +use Ardent\Undercurrent\Http\ResponseInterface; class BaseController { #[Route('/hello')] - public function HelloWorld(): string + public function HelloWorld(): ResponseInterface { - return 'Hello, World!'; + return new GenericResponse('Hello World!'); } } \ No newline at end of file diff --git a/src/Http/GenericRequest.php b/src/Http/GenericRequest.php new file mode 100644 index 0000000..c758a40 --- /dev/null +++ b/src/Http/GenericRequest.php @@ -0,0 +1,30 @@ +method; + } + + public function getUri(): string + { + return $this->uri; + } + + public function getBody(): array + { + return $this->body; + } +} \ No newline at end of file diff --git a/src/Http/GenericResponse.php b/src/Http/GenericResponse.php new file mode 100644 index 0000000..d80d350 --- /dev/null +++ b/src/Http/GenericResponse.php @@ -0,0 +1,23 @@ +status; + } + + public function getBody(): string + { + return $this->body; + } +} \ No newline at end of file diff --git a/src/Controller/GenericRouter.php b/src/Http/GenericRouter.php similarity index 89% rename from src/Controller/GenericRouter.php rename to src/Http/GenericRouter.php index 28f75b1..0332ce5 100644 --- a/src/Controller/GenericRouter.php +++ b/src/Http/GenericRouter.php @@ -1,6 +1,6 @@ add(GenericRouter::class); @@ -23,6 +24,6 @@ class BaseKernel $route = $router->getRoute($_SERVER['REQUEST_URI']); $controller = $container->get($route['controller']); $method = $route['method']; - echo $controller->$method(); + echo $controller->$method()->getBody(); } } \ No newline at end of file