我想知道用于编写REST API响应的实践: -
{
"Headline": {
"score": 10,
"summary": "Public Url Description.",
"status": 1,
"description": "Perfect! The URL contains your name"
},
"Profile Picture": {
"score": 10,
"summary": "Profile Picture Description.",
"status": 1,
"description": "Amazing Job, Now you are more approachable."
}
}
Run Code Online (Sandbox Code Playgroud)
要么
{
"status": 200,
"response": {
"Headline": {
"score": 10,
"summary": "Public Url Description.",
"status": 1,
"description": "Perfect! The URL contains your name"
},
"Profile Picture": {
"score": 10,
"summary": "Profile Picture Description.",
"status": 1,
"description": "Amazing Job, Now you are more approachable."
}
}
}
Run Code Online (Sandbox Code Playgroud)
我是编写API的新手.我想知道哪种做法可以帮助我编写更好的API.
我使用CakePHP作为框架.
我应该在API响应中添加响应代码吗?
小智 6
第二个响应复制已经处于HTTP响应状态的信息.HTTP状态将是200 OK
服务器设置的任何其他HTTP状态代码.如果你不小心保持两个值相等,那么在响应体中复制它只会导致混淆.
使用第一个表格.
归档时间: |
|
查看次数: |
490 次 |
最近记录: |