- Building Microservices with Go
- Nic Jackson
- 199字
- 2021-07-15 17:28:07
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.
推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- Bulma必知必會
- Internet of Things with the Arduino Yún
- 碼上行動:用ChatGPT學會Python編程
- Learning Salesforce Einstein
- 青少年信息學競賽
- HTML 5與CSS 3權威指南(第3版·上冊)
- C語言程序設計
- The Professional ScrumMaster’s Handbook
- 一本書講透Java線程:原理與實踐
- 小程序,巧應用:微信小程序開發實戰(第2版)
- 前端架構設計
- Analytics for the Internet of Things(IoT)
- Scala實用指南
- Instant JRebel