47 lines
1.1 KiB
PHP
Executable file
47 lines
1.1 KiB
PHP
Executable file
<?php
|
|
|
|
|
|
namespace MVC\Classe;
|
|
|
|
|
|
class HttpMethod
|
|
{
|
|
|
|
public $method;
|
|
protected $data;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->method = $_SERVER['REQUEST_METHOD'];
|
|
$this->acceptResponse();
|
|
}
|
|
|
|
private function acceptResponse()
|
|
{
|
|
switch ($this->method) {
|
|
case 'GET':
|
|
break;
|
|
case 'POST':
|
|
break;
|
|
case 'PUT':
|
|
//$this->data['GET'] = ...
|
|
//POST DATA except enctype="multipart/form-data"
|
|
$this->data = json_decode(file_get_contents("php://input"), true);
|
|
case 'DELETE':
|
|
//$this->data['GET'] = ...
|
|
//POST DATA except enctype="multipart/form-data"
|
|
$this->data = json_decode(file_get_contents("php://input"), true);
|
|
break;
|
|
default:
|
|
// Requête invalide
|
|
header("HTTP/1.0 405 Method Not Allowed");
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function getData()
|
|
{
|
|
return $this->data;
|
|
}
|
|
|
|
} |