From a6cfd218d681b475e6cd0eb782bb4a3400bcf3ef Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 23 Nov 2017 12:56:07 +0100 Subject: [PATCH] Barebone setup@3 > upd: routes.json (enable VIEW http method) | fix: api.Request --- build/api/core/Request.php | 8 ++++---- config/routes.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/api/core/Request.php b/build/api/core/Request.php index 3952d56..d263846 100755 --- a/build/api/core/Request.php +++ b/build/api/core/Request.php @@ -192,7 +192,7 @@ /* [3] On verifie que la methode est amorcable =========================================================*/ if( !is_callable([$instance, $this->getModuleMethod()]) ){ - $this->error->set(Err::UncallableMethod, preg_replace('/\w+::/i', '', $this->path['method']) ); + $this->error->set(Err::UncallableMethod, preg_replace('/[A-Z]+ /i', '', $this->path['method']) ); return new Response($this->error); } @@ -234,15 +234,15 @@ =========================================================*/ $instance = ModuleFactory::getModule($this->path['module']); - if( $instance === false ){ - $this->error->set(Err::UncallableModule); + if( $instance instanceof Error ){ + $this->error->set(Err::UncallableModule, $this->path['module']); return new Response($this->error); } /* [3] On verifie que la methode est amorcable =========================================================*/ if( !is_callable([$instance, $this->getModuleMethod()]) ){ - $this->error->set(Err::UncallableMethod); + $this->error->set(Err::UncallableMethod, preg_replace('/[A-Z]+ /i', '', $this->path['method']) ); return new Response($this->error); } diff --git a/config/routes.json b/config/routes.json index c1538f2..ed0596c 100755 --- a/config/routes.json +++ b/config/routes.json @@ -1,6 +1,6 @@ { - "methods": [ "GET", "POST", "PUT", "DELETE" ], + "methods": [ "GET", "POST", "PUT", "DELETE", "VIEW" ], "routes": { @@ -14,7 +14,7 @@ }, "/api/v/1.0/{module}/{method}{uri_args}": { - "methods": ["GET", "POST", "PUT", "DELETE"], + "methods": ["GET", "POST", "PUT", "DELETE", "VIEW"], "controller": "api:call", "arguments": { "module": "[a-zA-Z_]+",