1
在API中,我的工作,有一個終點,應該是通過POST請求特別營造出宛如如何爲POST請求定義REST端點,期望單個項目和列表?
{
"title": "foo title",
"description": "foo description"
}
一個單一的項目,但也喜歡
{
"items": [
{
"title": "foo title",
"description": "foo description"
},
{
"title": "bar title",
"description": "bar description"
},
{
"title": "buz title",
"description": "buz description"
}
]
}
項目列表
它是否符合REST,端點期望(並處理有效)多種類型的輸入(單個項目和列表)?或者應該只在這種情況下將一個列表定義爲有效輸入?
如何滿足要求並正確設計此端點?