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

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.

主站蜘蛛池模板: 正宁县| 穆棱市| 苏州市| 即墨市| 万盛区| 五河县| 丽水市| 湟中县| 射阳县| 辉南县| 蓝山县| 扶绥县| 桐城市| 砚山县| 峨眉山市| 桓仁| 雅江县| 明水县| 五峰| 鄱阳县| 白朗县| 景德镇市| 洛浦县| 乐亭县| 江津市| 买车| 自贡市| 嘉义市| 铁岭市| 大庆市| 新蔡县| 南宫市| 塔城市| 嘉兴市| 柘城县| 孟州市| 郁南县| 商水县| 泾阳县| 昌宁县| 大姚县|