- 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.
推薦閱讀
- Mastering OpenCV Android Application Programming
- 高效微控制器C語言編程
- 編程卓越之道(卷3):軟件工程化
- Learning Elixir
- Android 7編程入門經(jīng)典:使用Android Studio 2(第4版)
- Python 3網(wǎng)絡(luò)爬蟲實(shí)戰(zhàn)
- Mastering KnockoutJS
- Python時(shí)間序列預(yù)測
- 基于ARM Cortex-M4F內(nèi)核的MSP432 MCU開發(fā)實(shí)踐
- Scratch趣味編程:陪孩子像搭積木一樣學(xué)編程
- Modernizing Legacy Applications in PHP
- Keil Cx51 V7.0單片機(jī)高級語言編程與μVision2應(yīng)用實(shí)踐
- Java編程指南:語法基礎(chǔ)、面向?qū)ο蟆⒑瘮?shù)式編程與項(xiàng)目實(shí)戰(zhàn)
- Microsoft XNA 4.0 Game Development Cookbook
- JavaScript重難點(diǎn)實(shí)例精講