官术网_书友最值得收藏!

Principle 2 – Each resource is identifiable by a unique identifier

Since the internet contains so many different resources, they all should be accessible via URIs and should be identified uniquely. Furthermore, the URIs can be in a human-readable format, despite the fact that their consumers are more likely to be software programs rather than ordinary humans.

Human-readable URIs keep data self-descriptive and ease further development against it. This helps you to keep the risk of logical errors in your programs to a minimum.

Here are a few sample examples of such URIs representing different resources in a catalog application:

These human-readable URIs expose different types of resources in a straightforward manner. In the preceding example URIs, it is quite clear the data is items in a catalog, which are categorized watches. The first link shows all the items in the category. The second shows only the ones that are part of the 2018 collection. Next is a link pointing to the image of the item, followed by a link to a sample video. The last link points to a resource containing items from the previous collection in a ZIP archive. The media types served per each URI are rather easy to identify, with the assumption that the data format of an item is either JSON or XML, so we can easily map the media type of a self-described URL to one of the following:

  • JSON or XML documents describing the items
  • Images
  • Videos
  • Binary archive documents
主站蜘蛛池模板: 肃宁县| 岳池县| 孟州市| 巴东县| 金华市| 鄂温| 长岛县| 中江县| 通州区| 含山县| 渭源县| 南安市| 阳山县| 稻城县| 太谷县| 东光县| 灵寿县| 任丘市| 兴和县| 含山县| 溧阳市| 安远县| 孙吴县| 盘山县| 余姚市| 富裕县| 贵南县| 平江县| 文成县| 西乡县| 永靖县| 延川县| 中江县| 邹城市| 宜丰县| 涞源县| 聂荣县| 寻乌县| 达孜县| 巨野县| 平山县|