mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
让Request支持json方式的POST
目前RESTful API用json方式提交的很多 目前PUT/PATCH/DELETE方法均可以支持json,但POST方法不能,这不对等 其实更好的方法是判断header里content-type是否为application/json,但因为目前header属性采用的是懒加载,所以暂时沿用目前的字符串判断
This commit is contained in:
@@ -686,7 +686,12 @@ class Request
|
||||
public function post($name = '', $default = null, $filter = '')
|
||||
{
|
||||
if (empty($this->post)) {
|
||||
$this->post = $_POST;
|
||||
$content = $this->input;
|
||||
if (empty($_POST) && strpos($content, '":')) {
|
||||
$this->post = json_decode($content, true);
|
||||
} else {
|
||||
$this->post = $_POST;
|
||||
}
|
||||
}
|
||||
if (is_array($name)) {
|
||||
$this->param = [];
|
||||
|
||||
Reference in New Issue
Block a user