Browse Source

dev 2020-12

Max F 4 years ago
parent
commit
ea3e583fdf
1 changed files with 28 additions and 2 deletions
  1. 28 2
      src/Http/Response.php

+ 28 - 2
src/Http/Response.php

@@ -402,9 +402,9 @@ class Response
 	}
 
 
-	public function error404($body='', $content_type='text/html; charset=utf8')
+	public function error($status=500, $body='Error', $content_type='text/html; charset=utf8')
 	{
-		$this->setStatus(404)
+		$this->setStatus($status)
 			->setContentType($content_type)
 			->setBody($body);
 
@@ -412,6 +412,32 @@ class Response
 	}
 
 
+	public function error401($body='Unauthorized', $content_type='text/html; charset=utf8')
+	{
+		return $this->error(401, $body, $content_type);
+	}
+
+	public function error403($body='Forbidden', $content_type='text/html; charset=utf8')
+	{
+		return $this->error(403, $body, $content_type);
+	}
+
+	public function error404($body='Not Found', $content_type='text/html; charset=utf8')
+	{
+		return $this->error(404, $body, $content_type);
+	}
+
+	public function error500($body='Internal Server Error', $content_type='text/html; charset=utf8')
+	{
+		return $this->error(500, $body, $content_type);
+	}
+
+	public function error503($body='Service Unavailable', $content_type='text/html; charset=utf8')
+	{
+		return $this->error(503, $body, $content_type);
+	}
+
+
 	public function getAttributes()
 	{
 		return $this->attributes;