组织REST Web服务

时间:2014-06-13 16:59:30

标签: web-services rest

我正在尝试构建REST Web服务,但我不知道返回结果的正确方法。你能给我一些提示吗?

/countries/{id_country}/cities/{id_cities}/categories/
  • 选项1:

资源链接和资源描述的一些部分

[ { "id": 1,
    "name": "cine",
    "url": "http://domain/countries/1/cities/1/categories/1"
  },
  { "id": 2,
    "name": "restaurante",
    "url": "http://domain/countries/1/cities/1/categories/2"
  }
]
  • 选项2

资源链接

[ { "url": "http://domain/countries/1/universities/1/categories/1" },
  { "url": "http://domain/countries/1/universities/1/categories/2" },
] 
  • 选项3

资源描述

[ { "id": 1,
    "name": "cine",
    "description": "text text",
    "url": "http://domain/countries/1/cities/1/categories/1" },
  { "id": 2,
    "name": "restaurante",
    "description": "text text",
    "url": "http://domain/countries/1/cities/1/categories/2" }
]

0 个答案:

没有答案