【发布时间】:2013-04-24 17:35:26
【问题描述】:
我创建了一个 API。获取我的资源给出:
{
category: {
id: "517ed1bff929f90e1152ad43",
name: "Test category"
},
cost: "Free",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tincidunt augue in mi scelerisque quis condimentum velit sollicitudin. Nam eleifend posuere semper. Pellentesque non nulla et arcu ornare lacinia. Donec quis dui at velit placerat volutpat vitae sit amet lorem. ",
genders: [
"M",
"F"
],
id: "517ed1bff929f90e1152ad44",
tags: [
{
id: "517ed1bff929f90e1152ad3f",
name: "testing",
resource_uri: "/api/v1/interests/517ed1bff929f90e1152ad3f/"
},
{
id: "517ed1bff929f90e1152ad41",
name: "coding",
resource_uri: "/api/v1/interests/517ed1bff929f90e1152ad41/"
}
],
location: {
lat_lng: [
51.500705,
-0.124575
],
locality: "London",
name: "Big Ben"
},
resource_uri: "/api/v1/events/517ed1bff929f90e1152ad44/",
slug: "test-event1",
title: "Test event1"
}
我想允许用户将标签作为列表提交,例如['testing', 'coding', 'python'] 而不是要求他们提交对象 - 这是因为如果不存在标记对象,我将创建一个。
我怎么能用 sweetpie 做到这一点,它违反了 REST 原则?
【问题讨论】: