diff --git a/src/View.php b/src/View.php index d1dcf60..a27c7c2 100644 --- a/src/View.php +++ b/src/View.php @@ -7,6 +7,8 @@ use Vendimia\Exception\ResourceNotFoundException; use Vendimia\Http\Response; +use const Vendimia\DEBUG; + /** * Simple PHP view rendering engine */ @@ -158,4 +160,20 @@ public function renderResponse(): Response return $response; } + + /** + * Renders a HTTP status code special view. + */ + public function renderHttpStatus($code, $args): noreturn + { + $source = '::http-status/' . $code; + + if (DEBUG) { + $source .= '-debug'; + } + $this->setSource($source); + $this->addArguments($args); + $this->renderResponse()->withStatus($code)->send(); + exit; + } } \ No newline at end of file