Fix: Add html() method to Response class
This commit is contained in:
@@ -58,6 +58,25 @@ class Response
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send HTML response and terminate execution
|
||||
*
|
||||
* @param string $html
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
public function html(string $html, int $code = 200): void
|
||||
{
|
||||
$this->setStatusCode($code);
|
||||
$this->setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
|
||||
$this->sendHeaders();
|
||||
http_response_code($this->statusCode);
|
||||
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send success JSON response
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user