{"id":8922,"date":"2023-09-12T17:31:45","date_gmt":"2023-09-12T09:31:45","guid":{"rendered":"\/?p=8922"},"modified":"2023-09-12T17:31:45","modified_gmt":"2023-09-12T09:31:45","slug":"restful-api-%e8%ae%be%e8%ae%a1%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"\/?p=8922","title":{"rendered":"RESTful API \u8bbe\u8ba1\u6307\u5357"},"content":{"rendered":"<p>\u4f5c\u8005\uff1a\u962e\u4e00\u5cf0<\/p>\n<h2>\u6982\u8ff0<\/h2>\n<p>\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u5f00\u59cb\u610f\u8bc6\u5230\uff0c<strong>\u7f51\u7ad9\u5373\u8f6f\u4ef6<\/strong>\uff0c\u800c\u4e14\u662f\u4e00\u79cd\u65b0\u578b\u7684\u8f6f\u4ef6\u3002<\/p>\n<p>\u8fd9\u79cd\u201d\u4e92\u8054\u7f51\u8f6f\u4ef6\u201d\u91c7\u7528\u5ba2\u6237\u7aef\/\u670d\u52a1\u5668\u6a21\u5f0f\uff0c\u5efa\u7acb\u5728\u5206\u5e03\u5f0f\u4f53\u7cfb\u4e0a\uff0c\u901a\u8fc7\u4e92\u8054\u7f51\u901a\u4fe1\uff0c\u5177\u6709\u9ad8\u5ef6\u65f6\uff08high latency\uff09\u3001\u9ad8\u5e76\u53d1\u7b49\u7279\u70b9\u3002<\/p>\n<p>\u7f51\u7ad9\u5f00\u53d1\uff0c\u5b8c\u5168\u53ef\u4ee5\u91c7\u7528\u8f6f\u4ef6\u5f00\u53d1\u7684\u6a21\u5f0f\u3002\u4f46\u662f\u4f20\u7edf\u4e0a\uff0c\u8f6f\u4ef6\u548c\u7f51\u7edc\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u9886\u57df\uff0c\u5f88\u5c11\u6709\u4ea4\u96c6\uff1b\u8f6f\u4ef6\u5f00\u53d1\u4e3b\u8981\u9488\u5bf9\u5355\u673a\u73af\u5883\uff0c\u7f51\u7edc\u5219\u4e3b\u8981\u7814\u7a76\u7cfb\u7edf\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u4e92\u8054\u7f51\u7684\u5174\u8d77\uff0c\u4f7f\u5f97\u8fd9\u4e24\u4e2a\u9886\u57df\u5f00\u59cb\u878d\u5408\uff0c<strong>\u73b0\u5728\u6211\u4eec\u5fc5\u987b\u8003\u8651\uff0c\u5982\u4f55\u5f00\u53d1\u5728\u4e92\u8054\u7f51\u73af\u5883\u4e2d\u4f7f\u7528\u7684\u8f6f\u4ef6\u3002<\/strong><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/2023041516413469.jpeg\" alt=\"img\" \/><\/p>\n<p>RESTful\u67b6\u6784\uff0c\u5c31\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684\u4e00\u79cd\u4e92\u8054\u7f51\u8f6f\u4ef6\u67b6\u6784\u3002\u5b83\u7ed3\u6784\u6e05\u6670\u3001\u7b26\u5408\u6807\u51c6\u3001\u6613\u4e8e\u7406\u89e3\u3001\u6269\u5c55\u65b9\u4fbf\uff0c\u6240\u4ee5\u6b63\u5f97\u5230\u8d8a\u6765\u8d8a\u591a\u7f51\u7ad9\u7684\u91c7\u7528\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5230\u5e95\u4ec0\u4e48\u662fRESTful\u67b6\u6784\uff0c\u5e76\u4e0d\u662f\u4e00\u4e2a\u5bb9\u6613\u8bf4\u6e05\u695a\u7684\u95ee\u9898\u3002\u4e0b\u9762\uff0c\u6211\u5c31\u8c08\u8c08\u6211\u7406\u89e3\u7684RESTful\u67b6\u6784\u3002<\/p>\n<h2><strong>\u4e00\u3001\u8d77\u6e90<\/strong><\/h2>\n<p>REST\u8fd9\u4e2a\u8bcd\uff0c\u662fRoy Thomas Fielding\u5728\u4ed62000\u5e74\u7684\u535a\u58eb\u8bba\u6587\u4e2d\u63d0\u51fa\u7684\u3002<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/2023041516415094.jpeg\" alt=\"img\" \/><\/p>\n<p>Fielding\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u4eba\uff0c\u4ed6\u662fHTTP\u534f\u8bae\uff081.0\u7248\u548c1.1\u7248\uff09\u7684\u4e3b\u8981\u8bbe\u8ba1\u8005\u3001Apache\u670d\u52a1\u5668\u8f6f\u4ef6\u7684\u4f5c\u8005\u4e4b\u4e00\u3001Apache\u57fa\u91d1\u4f1a\u7684\u7b2c\u4e00\u4efb\u4e3b\u5e2d\u3002\u6240\u4ee5\uff0c\u4ed6\u7684\u8fd9\u7bc7\u8bba\u6587\u4e00\u7ecf\u53d1\u8868\uff0c\u5c31\u5f15\u8d77\u4e86\u5173\u6ce8\uff0c\u5e76\u4e14\u7acb\u5373\u5bf9\u4e92\u8054\u7f51\u5f00\u53d1\u4ea7\u751f\u4e86\u6df1\u8fdc\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u4ed6\u8fd9\u6837\u4ecb\u7ecd\u8bba\u6587\u7684\u5199\u4f5c\u76ee\u7684\uff1a<\/p>\n<blockquote>\n<p>\u201c\u672c\u6587\u7814\u7a76\u8ba1\u7b97\u673a\u79d1\u5b66\u4e24\u5927\u524d\u6cbf\u2014-\u8f6f\u4ef6\u548c\u7f51\u7edc\u2014-\u7684\u4ea4\u53c9\u70b9\u3002\u957f\u671f\u4ee5\u6765\uff0c\u8f6f\u4ef6\u7814\u7a76\u4e3b\u8981\u5173\u6ce8\u8f6f\u4ef6\u8bbe\u8ba1\u7684\u5206\u7c7b\u3001\u8bbe\u8ba1\u65b9\u6cd5\u7684\u6f14\u5316\uff0c\u5f88\u5c11\u5ba2\u89c2\u5730\u8bc4\u4f30\u4e0d\u540c\u7684\u8bbe\u8ba1\u9009\u62e9\u5bf9\u7cfb\u7edf\u884c\u4e3a\u7684\u5f71\u54cd\u3002\u800c\u76f8\u53cd\u5730\uff0c\u7f51\u7edc\u7814\u7a76\u4e3b\u8981\u5173\u6ce8\u7cfb\u7edf\u4e4b\u95f4\u901a\u4fe1\u884c\u4e3a\u7684\u7ec6\u8282\u3001\u5982\u4f55\u6539\u8fdb\u7279\u5b9a\u901a\u4fe1\u673a\u5236\u7684\u8868\u73b0\uff0c\u5e38\u5e38\u5ffd\u89c6\u4e86\u4e00\u4e2a\u4e8b\u5b9e\uff0c\u90a3\u5c31\u662f\u6539\u53d8\u5e94\u7528\u7a0b\u5e8f\u7684\u4e92\u52a8\u98ce\u683c\u6bd4\u6539\u53d8\u4e92\u52a8\u534f\u8bae\uff0c\u5bf9\u6574\u4f53\u8868\u73b0\u6709\u66f4\u5927\u7684\u5f71\u54cd\u3002<strong>\u6211\u8fd9\u7bc7\u6587\u7ae0\u7684\u5199\u4f5c\u76ee\u7684\uff0c\u5c31\u662f\u60f3\u5728\u7b26\u5408\u67b6\u6784\u539f\u7406\u7684\u524d\u63d0\u4e0b\uff0c\u7406\u89e3\u548c\u8bc4\u4f30\u4ee5\u7f51\u7edc\u4e3a\u57fa\u7840\u7684\u5e94\u7528\u8f6f\u4ef6\u7684\u67b6\u6784\u8bbe\u8ba1\uff0c\u5f97\u5230\u4e00\u4e2a\u529f\u80fd\u5f3a\u3001\u6027\u80fd\u597d\u3001\u9002\u5b9c\u901a\u4fe1\u7684\u67b6\u6784\u3002<\/strong>\u201c<\/p>\n<p>(This dissertation explores a junction on the frontiers of two research disciplines in computer science: software and networking. Software research has long been concerned with the categorization of software designs and the development of design methodologies, but has rarely been able to objectively evaluate the impact of various design choices on system behavior. Networking research, in contrast, is focused on the details of generic communication behavior between systems and improving the performance of particular communication techniques, often ignoring the fact that changing the interaction style of an application can have more impact on performance than the communication protocols used for that interaction. My work is motivated by the desire to understand and evaluate the architectural design of network-based application software through principled use of architectural constraints, thereby obtaining the functional, performance, and social properties desired of an architecture. )<\/p>\n<\/blockquote>\n<h2><strong>\u4e8c\u3001\u540d\u79f0<\/strong><\/h2>\n<p>Fielding\u5c06\u4ed6\u5bf9\u4e92\u8054\u7f51\u8f6f\u4ef6\u7684\u67b6\u6784\u539f\u5219\uff0c\u5b9a\u540d\u4e3aREST\uff0c\u5373Representational State Transfer\u7684\u7f29\u5199\u3002\u6211\u5bf9\u8fd9\u4e2a\u8bcd\u7ec4\u7684\u7ffb\u8bd1\u662f\u201d\u8868\u73b0\u5c42\u72b6\u6001\u8f6c\u5316\u201d\u3002<\/p>\n<p>\u5982\u679c\u4e00\u4e2a\u67b6\u6784\u7b26\u5408REST\u539f\u5219\uff0c\u5c31\u79f0\u5b83\u4e3aRESTful\u67b6\u6784\u3002<\/p>\n<p><strong>\u8981\u7406\u89e3RESTful\u67b6\u6784\uff0c\u6700\u597d\u7684\u65b9\u6cd5\u5c31\u662f\u53bb\u7406\u89e3Representational State Transfer\u8fd9\u4e2a\u8bcd\u7ec4\u5230\u5e95\u662f\u4ec0\u4e48\u610f\u601d\uff0c\u5b83\u7684\u6bcf\u4e00\u4e2a\u8bcd\u4ee3\u8868\u4e86\u4ec0\u4e48\u6db5\u4e49\u3002<\/strong>\u5982\u679c\u4f60\u628a\u8fd9\u4e2a\u540d\u79f0\u641e\u61c2\u4e86\uff0c\u4e5f\u5c31\u4e0d\u96be\u4f53\u4f1aREST\u662f\u4e00\u79cd\u4ec0\u4e48\u6837\u7684\u8bbe\u8ba1\u3002<\/p>\n<h2><strong>\u4e09\u3001\u8d44\u6e90\uff08Resources\uff09<\/strong><\/h2>\n<p>REST\u7684\u540d\u79f0\u201d\u8868\u73b0\u5c42\u72b6\u6001\u8f6c\u5316\u201d\u4e2d\uff0c\u7701\u7565\u4e86\u4e3b\u8bed\u3002\u201d\u8868\u73b0\u5c42\u201d\u5176\u5b9e\u6307\u7684\u662f\u201d\u8d44\u6e90\u201d\uff08Resources\uff09\u7684\u201d\u8868\u73b0\u5c42\u201d\u3002<\/p>\n<p><strong>\u6240\u8c13\u201d\u8d44\u6e90\u201d\uff0c\u5c31\u662f\u7f51\u7edc\u4e0a\u7684\u4e00\u4e2a\u5b9e\u4f53\uff0c\u6216\u8005\u8bf4\u662f\u7f51\u7edc\u4e0a\u7684\u4e00\u4e2a\u5177\u4f53\u4fe1\u606f\u3002<\/strong>\u5b83\u53ef\u4ee5\u662f\u4e00\u6bb5\u6587\u672c\u3001\u4e00\u5f20\u56fe\u7247\u3001\u4e00\u9996\u6b4c\u66f2\u3001\u4e00\u79cd\u670d\u52a1\uff0c\u603b\u4e4b\u5c31\u662f\u4e00\u4e2a\u5177\u4f53\u7684\u5b9e\u5728\u3002\u4f60\u53ef\u4ee5\u7528\u4e00\u4e2aURI\uff08\u7edf\u4e00\u8d44\u6e90\u5b9a\u4f4d\u7b26\uff09\u6307\u5411\u5b83\uff0c\u6bcf\u79cd\u8d44\u6e90\u5bf9\u5e94\u4e00\u4e2a\u7279\u5b9a\u7684URI\u3002\u8981\u83b7\u53d6\u8fd9\u4e2a\u8d44\u6e90\uff0c\u8bbf\u95ee\u5b83\u7684URI\u5c31\u53ef\u4ee5\uff0c\u56e0\u6b64URI\u5c31\u6210\u4e86\u6bcf\u4e00\u4e2a\u8d44\u6e90\u7684\u5730\u5740\u6216\u72ec\u4e00\u65e0\u4e8c\u7684\u8bc6\u522b\u7b26\u3002<\/p>\n<p>\u6240\u8c13\u201d\u4e0a\u7f51\u201d\uff0c\u5c31\u662f\u4e0e\u4e92\u8054\u7f51\u4e0a\u4e00\u7cfb\u5217\u7684\u201d\u8d44\u6e90\u201d\u4e92\u52a8\uff0c\u8c03\u7528\u5b83\u7684URI\u3002<\/p>\n<h2><strong>\u56db\u3001\u8868\u73b0\u5c42\uff08Representation\uff09<\/strong><\/h2>\n<p>\u201c\u8d44\u6e90\u201d\u662f\u4e00\u79cd\u4fe1\u606f\u5b9e\u4f53\uff0c\u5b83\u53ef\u4ee5\u6709\u591a\u79cd\u5916\u5728\u8868\u73b0\u5f62\u5f0f\u3002<strong>\u6211\u4eec\u628a\u201d\u8d44\u6e90\u201d\u5177\u4f53\u5448\u73b0\u51fa\u6765\u7684\u5f62\u5f0f\uff0c\u53eb\u505a\u5b83\u7684\u201d\u8868\u73b0\u5c42\u201d\uff08Representation\uff09\u3002<\/strong><\/p>\n<p>\u6bd4\u5982\uff0c\u6587\u672c\u53ef\u4ee5\u7528txt\u683c\u5f0f\u8868\u73b0\uff0c\u4e5f\u53ef\u4ee5\u7528HTML\u683c\u5f0f\u3001XML\u683c\u5f0f\u3001JSON\u683c\u5f0f\u8868\u73b0\uff0c\u751a\u81f3\u53ef\u4ee5\u91c7\u7528\u4e8c\u8fdb\u5236\u683c\u5f0f\uff1b\u56fe\u7247\u53ef\u4ee5\u7528JPG\u683c\u5f0f\u8868\u73b0\uff0c\u4e5f\u53ef\u4ee5\u7528PNG\u683c\u5f0f\u8868\u73b0\u3002<\/p>\n<p>URI\u53ea\u4ee3\u8868\u8d44\u6e90\u7684\u5b9e\u4f53\uff0c\u4e0d\u4ee3\u8868\u5b83\u7684\u5f62\u5f0f\u3002\u4e25\u683c\u5730\u8bf4\uff0c\u6709\u4e9b\u7f51\u5740\u6700\u540e\u7684\u201d.html\u201d\u540e\u7f00\u540d\u662f\u4e0d\u5fc5\u8981\u7684\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u540e\u7f00\u540d\u8868\u793a\u683c\u5f0f\uff0c\u5c5e\u4e8e\u201d\u8868\u73b0\u5c42\u201d\u8303\u7574\uff0c\u800cURI\u5e94\u8be5\u53ea\u4ee3\u8868\u201d\u8d44\u6e90\u201d\u7684\u4f4d\u7f6e\u3002\u5b83\u7684\u5177\u4f53\u8868\u73b0\u5f62\u5f0f\uff0c\u5e94\u8be5\u5728HTTP\u8bf7\u6c42\u7684\u5934\u4fe1\u606f\u4e2d\u7528Accept\u548cContent-Type\u5b57\u6bb5\u6307\u5b9a\uff0c\u8fd9\u4e24\u4e2a\u5b57\u6bb5\u624d\u662f\u5bf9\u201d\u8868\u73b0\u5c42\u201d\u7684\u63cf\u8ff0\u3002<\/p>\n<h2><strong>\u4e94\u3001\u72b6\u6001\u8f6c\u5316\uff08State Transfer\uff09<\/strong><\/h2>\n<p>\u8bbf\u95ee\u4e00\u4e2a\u7f51\u7ad9\uff0c\u5c31\u4ee3\u8868\u4e86\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7684\u4e00\u4e2a\u4e92\u52a8\u8fc7\u7a0b\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u52bf\u5fc5\u6d89\u53ca\u5230\u6570\u636e\u548c\u72b6\u6001\u7684\u53d8\u5316\u3002<\/p>\n<p>\u4e92\u8054\u7f51\u901a\u4fe1\u534f\u8baeHTTP\u534f\u8bae\uff0c\u662f\u4e00\u4e2a\u65e0\u72b6\u6001\u534f\u8bae\u3002\u8fd9\u610f\u5473\u7740\uff0c\u6240\u6709\u7684\u72b6\u6001\u90fd\u4fdd\u5b58\u5728\u670d\u52a1\u5668\u7aef\u3002\u56e0\u6b64\uff0c<strong>\u5982\u679c\u5ba2\u6237\u7aef\u60f3\u8981\u64cd\u4f5c\u670d\u52a1\u5668\uff0c\u5fc5\u987b\u901a\u8fc7\u67d0\u79cd\u624b\u6bb5\uff0c\u8ba9\u670d\u52a1\u5668\u7aef\u53d1\u751f\u201d\u72b6\u6001\u8f6c\u5316\u201d\uff08State Transfer\uff09\u3002\u800c\u8fd9\u79cd\u8f6c\u5316\u662f\u5efa\u7acb\u5728\u8868\u73b0\u5c42\u4e4b\u4e0a\u7684\uff0c\u6240\u4ee5\u5c31\u662f\u201d\u8868\u73b0\u5c42\u72b6\u6001\u8f6c\u5316\u201d\u3002<\/strong><\/p>\n<p>\u5ba2\u6237\u7aef\u7528\u5230\u7684\u624b\u6bb5\uff0c\u53ea\u80fd\u662fHTTP\u534f\u8bae\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5c31\u662fHTTP\u534f\u8bae\u91cc\u9762\uff0c\u56db\u4e2a\u8868\u793a\u64cd\u4f5c\u65b9\u5f0f\u7684\u52a8\u8bcd\uff1aGET\u3001POST\u3001PUT\u3001DELETE\u3002\u5b83\u4eec\u5206\u522b\u5bf9\u5e94\u56db\u79cd\u57fa\u672c\u64cd\u4f5c\uff1a<strong>GET\u7528\u6765\u83b7\u53d6\u8d44\u6e90\uff0cPOST\u7528\u6765\u65b0\u5efa\u8d44\u6e90\uff08\u4e5f\u53ef\u4ee5\u7528\u4e8e\u66f4\u65b0\u8d44\u6e90\uff09\uff0cPUT\u7528\u6765\u66f4\u65b0\u8d44\u6e90\uff0cDELETE\u7528\u6765\u5220\u9664\u8d44\u6e90\u3002<\/strong><\/p>\n<h2><strong>\u516d\u3001\u7efc\u8ff0<\/strong><\/h2>\n<p>\u7efc\u5408\u4e0a\u9762\u7684\u89e3\u91ca\uff0c\u6211\u4eec\u603b\u7ed3\u4e00\u4e0b\u4ec0\u4e48\u662fRESTful\u67b6\u6784\uff1a<\/p>\n<p>\u3000\u3000\uff081\uff09\u6bcf\u4e00\u4e2aURI\u4ee3\u8868\u4e00\u79cd\u8d44\u6e90\uff1b<\/p>\n<p>\u3000\u3000\uff082\uff09\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\uff0c\u4f20\u9012\u8fd9\u79cd\u8d44\u6e90\u7684\u67d0\u79cd\u8868\u73b0\u5c42\uff1b<\/p>\n<p>\u3000\u3000\uff083\uff09\u5ba2\u6237\u7aef\u901a\u8fc7\u56db\u4e2aHTTP\u52a8\u8bcd\uff0c\u5bf9\u670d\u52a1\u5668\u7aef\u8d44\u6e90\u8fdb\u884c\u64cd\u4f5c\uff0c\u5b9e\u73b0\u201d\u8868\u73b0\u5c42\u72b6\u6001\u8f6c\u5316\u201d\u3002<\/p>\n<h2><strong>\u4e03\u3001\u8bef\u533a<\/strong><\/h2>\n<p>RESTful\u67b6\u6784\u6709\u4e00\u4e9b\u5178\u578b\u7684\u8bbe\u8ba1\u8bef\u533a\u3002<\/p>\n<p><strong>\u6700\u5e38\u89c1\u7684\u4e00\u79cd\u8bbe\u8ba1\u9519\u8bef\uff0c\u5c31\u662fURI\u5305\u542b\u52a8\u8bcd\u3002<\/strong>\u56e0\u4e3a\u201d\u8d44\u6e90\u201d\u8868\u793a\u4e00\u79cd\u5b9e\u4f53\uff0c\u6240\u4ee5\u5e94\u8be5\u662f\u540d\u8bcd\uff0cURI\u4e0d\u5e94\u8be5\u6709\u52a8\u8bcd\uff0c\u52a8\u8bcd\u5e94\u8be5\u653e\u5728HTTP\u534f\u8bae\u4e2d\u3002<\/p>\n<p>\u4e3e\u4f8b\u6765\u8bf4\uff0c\u67d0\u4e2aURI\u662f\/posts\/show\/1\uff0c\u5176\u4e2dshow\u662f\u52a8\u8bcd\uff0c\u8fd9\u4e2aURI\u5c31\u8bbe\u8ba1\u9519\u4e86\uff0c\u6b63\u786e\u7684\u5199\u6cd5\u5e94\u8be5\u662f\/posts\/1\uff0c\u7136\u540e\u7528GET\u65b9\u6cd5\u8868\u793ashow\u3002<\/p>\n<p>\u5982\u679c\u67d0\u4e9b\u52a8\u4f5c\u662fHTTP\u52a8\u8bcd\u8868\u793a\u4e0d\u4e86\u7684\uff0c\u4f60\u5c31\u5e94\u8be5\u628a\u52a8\u4f5c\u505a\u6210\u4e00\u79cd\u8d44\u6e90\u3002\u6bd4\u5982\u7f51\u4e0a\u6c47\u6b3e\uff0c\u4ece\u8d26\u62371\u5411\u8d26\u62372\u6c47\u6b3e500\u5143\uff0c\u9519\u8bef\u7684URI\u662f\uff1a<\/p>\n<pre><code>POST \/accounts\/1\/transfer\/500\/to\/2<\/code><\/pre>\n<p>\u6b63\u786e\u7684\u5199\u6cd5\u662f\u628a\u52a8\u8bcdtransfer\u6539\u6210\u540d\u8bcdtransaction\uff0c\u8d44\u6e90\u4e0d\u80fd\u662f\u52a8\u8bcd\uff0c\u4f46\u662f\u53ef\u4ee5\u662f\u4e00\u79cd\u670d\u52a1\uff1a<\/p>\n<pre><code>POST \/transaction HTTP\/1.1\nHost: 127.0.0.1\n\nfrom=1&amp;to=2&amp;amount=500.00<\/code><\/pre>\n<p><strong>\u53e6\u4e00\u4e2a\u8bbe\u8ba1\u8bef\u533a\uff0c\u5c31\u662f\u5728URI\u4e2d\u52a0\u5165\u7248\u672c\u53f7<\/strong>\uff1a<\/p>\n<pre><code>http:\/\/www.example.com\/app\/1.0\/foo\n\nhttp:\/\/www.example.com\/app\/1.1\/foo\n\nhttp:\/\/www.example.com\/app\/2.0\/foo<\/code><\/pre>\n<p>\u56e0\u4e3a\u4e0d\u540c\u7684\u7248\u672c\uff0c\u53ef\u4ee5\u7406\u89e3\u6210\u540c\u4e00\u79cd\u8d44\u6e90\u7684\u4e0d\u540c\u8868\u73b0\u5f62\u5f0f\uff0c\u6240\u4ee5\u5e94\u8be5\u91c7\u7528\u540c\u4e00\u4e2aURI\u3002\u7248\u672c\u53f7\u53ef\u4ee5\u5728HTTP\u8bf7\u6c42\u5934\u4fe1\u606f\u7684Accept\u5b57\u6bb5\u4e2d\u8fdb\u884c\u533a\u5206\uff08\u53c2\u89c1Versioning REST Services\uff09\uff1a<\/p>\n<pre><code>Accept: vnd.example-com.foo+json; version=1.0\n\nAccept: vnd.example-com.foo+json; version=1.1\n\nAccept: vnd.example-com.foo+json; version=2.0<\/code><\/pre>\n<p>\u4f5c\u8005\uff1a\u962e\u4e00\u5cf0<\/p>\n<p>\u6765\u6e90\uff1a<a href=\"https:\/\/www.ruanyifeng.com\/blog\/2014\/05\/restful_api.html\">https:\/\/www.ruanyifeng.com\/blog\/2014\/05\/restful_api.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u962e\u4e00\u5cf0 \u6982\u8ff0 \u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u5f00\u59cb\u610f\u8bc6\u5230\uff0c\u7f51\u7ad9\u5373\u8f6f\u4ef6\uff0c\u800c\u4e14\u662f\u4e00\u79cd\u65b0\u578b\u7684\u8f6f\u4ef6\u3002 \u8fd9\u79cd\u201d\u4e92\u8054\u7f51\u8f6f\u4ef6\u201d\u91c7\u7528\u5ba2\u6237\u7aef\/\u670d\u52a1\u5668\u6a21\u5f0f\uff0c\u5efa\u7acb\u5728\u5206\u5e03\u5f0f\u4f53   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[190],"tags":[203],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8922"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8922"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8922\/revisions"}],"predecessor-version":[{"id":8923,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8922\/revisions\/8923"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8922"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}