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

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.

主站蜘蛛池模板: 长兴县| 丹东市| 四平市| 白玉县| 珲春市| 天峻县| 合肥市| 清镇市| 微博| 象山县| 于都县| 贺州市| 榆中县| 沈阳市| 双鸭山市| 团风县| 集安市| 中阳县| 吉木萨尔县| 南安市| 青阳县| 天柱县| 大邑县| 中方县| 龙井市| 金寨县| 东光县| 贵阳市| 龙海市| 金平| 宜都市| 衡山县| 五峰| 内丘县| 德惠市| 科技| 伊春市| 蒙山县| 咸丰县| 侯马市| 讷河市|