2017-10-29 12 views
0

私はPhil Sturgeon's REST serverで作業しています。私は(単なるテストデータ)を持っているシンプルなブログテーブルのGET要求から次のような出力が得られます。Phil SturgeonのRESTサーバー、PHP、Codeigniterで奇妙なJSON出力

{ 
"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" 
} 

URLはこのようなものです:私はget要求を行うとき、しかし

https://www.example.com/v1/Blog/blog/id/1 

存在しないIDの場合は、次のようになります。

No webpage was found for the web address: 
https://www.example.com/v1/Blog/blog/id/233 
HTTP ERROR 404 

データが見つからないと考えていました。どのように実装されていますか?

答えて

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 
関連する問題