From 07d608fdaf797d1a07d1f2312523a9e85160a3bf Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 2 Jun 2016 22:28:45 +0200 Subject: [PATCH] Gestion du code d'erreur 200 ou 417 --- index.php | 2 +- manager/ManagerError.php | 5 +++++ manager/ModuleResponse.php | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.php b/index.php index f857c40..3f4dc7b 100755 --- a/index.php +++ b/index.php @@ -98,7 +98,7 @@ // Api - $R->post('api/?', function(){ + $R->post('api.+', function(){ $request = ModuleRequest::fromPost($_POST); $answer = $request->dispatch(); diff --git a/manager/ManagerError.php b/manager/ManagerError.php index a92d335..d6a5994 100755 --- a/manager/ManagerError.php +++ b/manager/ManagerError.php @@ -117,6 +117,11 @@ return null; } + + public static function setHttpCode($error){ + http_response_code( $error == self::Success ? 200 : 417 ); + } + } ?> diff --git a/manager/ModuleResponse.php b/manager/ModuleResponse.php index f908d01..0c45e4e 100755 --- a/manager/ModuleResponse.php +++ b/manager/ModuleResponse.php @@ -136,6 +136,9 @@ */ public function serialize(){ + // Code Http + ManagerError::setHttpCode($this->error); + // On rajoute l'erreur au message $returnData = array_merge( array(