fix: api.core.Request (now can force a HTTP_METHOD when called inside php (3rd argument))
This commit is contained in:
parent
6399608ef5
commit
cf35a8ade4
|
@ -38,13 +38,14 @@
|
|||
*
|
||||
* @path<String> Chemin de delegation ("module/methode")
|
||||
* @param<Array> Tableau associatif contenant les parametres utiles au traitement
|
||||
* @forced_method<String> Méthode demandée (optionnel)
|
||||
*
|
||||
* @return instance<Request> Instance crée
|
||||
*
|
||||
*/
|
||||
public function __construct($path=null, $params=null){
|
||||
public function __construct($path=null, $params=null, $forced_method=null){
|
||||
|
||||
return $this->buildRequestObject($path, $params);
|
||||
return $this->buildRequestObject($path, $params, $forced_method);
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,11 +55,12 @@
|
|||
*
|
||||
* @path<String> Chemin de delegation ("module/methode")
|
||||
* @param<Array> Tableau associatif contenant les parametres utiles au traitement
|
||||
* @forced_method<String> Méthode demandée (optionnel)
|
||||
*
|
||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien passe
|
||||
*
|
||||
*/
|
||||
private function buildRequestObject($path=null, $params=null){
|
||||
private function buildRequestObject($path=null, $params=null, $forced_method=null){
|
||||
/* [1] Initialisation
|
||||
=========================================================*/
|
||||
/* (1) Erreur par défaut */
|
||||
|
@ -101,10 +103,10 @@
|
|||
$params = (is_array($params)) ? $params : [];
|
||||
|
||||
/* (3) On définit en constante la méthode HTTP */
|
||||
if( !isset($_SERVER['REQUEST_METHOD']) )
|
||||
if( !isset($_SERVER['REQUEST_METHOD']) || !is_string($forced_method) )
|
||||
return $this->error->set(Err::UnknownHttpMethod);
|
||||
|
||||
$this->http_method = strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
$this->http_method = is_string($forced_method) ? strtoupper($forced_method) : strtoupper($_SERVER['REQUEST_METHOD']);
|
||||
|
||||
|
||||
/* [4] Verification du chemin (existence module+methode)
|
||||
|
|
Loading…
Reference in New Issue