diff --git a/composer.json b/composer.json index 9d0a3a2..b03439c 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "martywallace/tempest", - "version": "3.0.0", + "version": "3.0.1", "description": "A tiny PHP framework.", "homepage": "https://github.com/MartyWallace/Tempest", "type": "library", diff --git a/src/Tempest/Http/Router.php b/src/Tempest/Http/Router.php index 88240bc..6660b21 100644 --- a/src/Tempest/Http/Router.php +++ b/src/Tempest/Http/Router.php @@ -90,7 +90,12 @@ public function dispatch() { } if ($respond) { - $this->_response->body = $this->instantiateAndCall($this->baseControllerNamespace . ltrim($this->_matched->controller, '\\'), $this->_request, $this->_response); + $controllerValue = $this->instantiateAndCall($this->baseControllerNamespace . ltrim($this->_matched->controller, '\\'), $this->_request, $this->_response); + + if (!empty($controllerValue)) { + // If the controller returns a non-empty value, overwrite the response body with that value. + $this->_response->body = $controllerValue; + } } }