我正在与Phil Sturgeon's REST server合作。我从一个简单的博客表(仅测试数据)的GET请求中得到以下输出:
{
"user_id": "1",
"entryid": "1",
"entry_name": "twkla nnn xxx",
"entry_body": "this is just UPDATED",
"status": "active",
"created_timestamp": "2016-05-01 21:25:51",
"updated_timestamp": "2016-11-12 17:29:38"
}
网址是这样的:
https://www.example.com/v1/Blog/blog/id/1
但是,当我为不存在的id发出get请求时,我得到以下内容:
No webpage was found for the web address:
https://www.example.com/v1/Blog/blog/id/233
HTTP ERROR 404
我希望它能说没有找到数据。这是如何实现的?
答案 0 :(得分:0)
抱歉,有很多方法可以回复资源请求。以下是没有发现此类博客的回复;
// Set the response and exit
$this->response([
'status' => FALSE,
'message' => 'No such blog was found'
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code