Browse Source

Merge branch 'master' of ssh://gogs.karmas.fr/KarmaSolutions/KarmaFW

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

+ 28 - 2
src/Http/Response.php

@@ -406,9 +406,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);
 
@@ -416,6 +416,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;