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

URI format

RFC 3986, which was published in 2005 https://www.ietf.org/rfc/rfc3986.txt, defines the format that makes valid URIs:

URI = scheme "://" authority "/" path [ "?" query] ["#" fragment"] 
URI = http://myserver.com/mypath?query=1#document

We are will use the path element in order to locate an endpoint that is running on our server. In a REST endpoint, this can contain parameters as well as a document location. The query string is equally important, as you will use this to pass parameters such as page number or ordering to control the data that is returned.

Some general rules for URI formatting:

  • A forward slash / is used to indicate a hierarchical relationship between resources
  • A trailing forward slash / should not be included in URIs
  • Hyphens - should be used to improve readability
  • Underscores _ should not be used in URIs
  • Lowercase letters are preferred as case sensitivity is a differentiator in the path part of a URI

The concept behind many of the rules is that a URI should be easy to read and to construct. It should also be consistent in the way that it is built so you should follow the same taxonomy for all the endpoints in your API.

主站蜘蛛池模板: 汨罗市| 凌源市| 逊克县| 邵阳市| 仙居县| 漳浦县| 杭锦旗| 禄丰县| 商水县| 长子县| 汽车| 上饶县| 柘城县| 涿州市| 田阳县| 渑池县| 密云县| 南澳县| 花莲市| 浦城县| 延庆县| 梅河口市| 南涧| 嘉善县| 吴川市| 遵义县| 塘沽区| 中方县| 贺兰县| 沁源县| 彰武县| 图们市| 孟州市| 西安市| 舒兰市| 克什克腾旗| 嵊泗县| 玉环县| 偏关县| 苏尼特左旗| 泰宁县|