- 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.
推薦閱讀
- 數據庫程序員面試筆試真題與解析
- AngularJS Testing Cookbook
- CentOS 7 Server Deployment Cookbook
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- 小程序,巧運營:微信小程序運營招式大全
- Instant RubyMotion App Development
- Expert Data Visualization
- 青少年學Python(第1冊)
- Linux:Embedded Development
- WordPress 4.0 Site Blueprints(Second Edition)
- Python爬蟲、數據分析與可視化:工具詳解與案例實戰
- JavaScript程序設計:基礎·PHP·XML
- C++程序設計教程
- INSTANT Apache Hive Essentials How-to
- Android高級開發實戰:UI、NDK與安全