{"id":3080,"date":"2019-04-05T17:13:03","date_gmt":"2019-04-05T09:13:03","guid":{"rendered":"https:\/\/damogame.cn:15443\/wordpress\/?p=3080"},"modified":"2019-04-05T17:13:03","modified_gmt":"2019-04-05T09:13:03","slug":"rest%ef%bc%8c%e4%bb%a5%e5%8f%8arestful%e7%9a%84%e8%ae%b2%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/3080","title":{"rendered":"REST\uff0c\u4ee5\u53caRESTful\u7684\u8bb2\u89e3"},"content":{"rendered":"<div class=\"article-header-box\">\n<div class=\"article-header\">\n<div class=\"article-title-box\"><\/div>\n<\/div>\n<\/div>\n<article class=\"baidu_pl\">\n<div id=\"article_content\" class=\"article_content clearfix csdn-tracking-statistics\" data-pid=\"blog\" data-mod=\"popu_307\" data-dsm=\"post\">\n<div id=\"content_views\" class=\"markdown_views\">\n<div class=\"toc\">\n<ul>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#1%E4%BC%A0%E7%BB%9F%E4%B8%8B%E7%9A%84api%E6%8E%A5%E5%8F%A3\" target=\"_self\" rel=\"nofollow noopener noreferrer\">1.\u4f20\u7edf\u4e0b\u7684API\u63a5\u53e3<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E5%AF%B9%E6%AF%94\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u5bf9\u6bd4<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E8%A7%84%E5%88%99\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u89c4\u5219<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E6%A6%82%E5%BF%B5\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u6982\u5ff5<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#rest-%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%B9%E5%BE%81\" target=\"_self\" rel=\"nofollow noopener noreferrer\">REST \u7cfb\u7edf\u7684\u7279\u5f81<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E6%BC%94%E5%8C%96\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u6f14\u5316<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E4%BC%98%E7%82%B9%E7%BC%BA%E7%82%B9\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u4f18\u70b9&amp;\u7f3a\u70b9<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/qq_21383435\/article\/details\/80032375#%E6%98%AF%E4%BB%80%E4%B9%88\" target=\"_self\" rel=\"nofollow noopener noreferrer\">\u662f\u4ec0\u4e48\uff1f<\/a><\/li>\n<\/ul>\n<\/div>\n<h1 id=\"1\u4f20\u7edf\u4e0b\u7684api\u63a5\u53e3\">1.\u4f20\u7edf\u4e0b\u7684API\u63a5\u53e3<\/h1>\n<p>http\u662f\u76ee\u524d\u5728\u4e92\u8054\u7f51\u4e0a\u4f7f\u7528\u6700\u591a\u7684\u534f\u8bae\uff0c\u6ca1\u6709\u4e4b\u4e00\u3002<br \/>\n\u53ef\u662fhttp\u7684\u521b\u59cb\u4eba\u4e00\u76f4\u90fd\u89c9\u5f97\uff0c\u5728\u8fc7\u53bb10\u51e0\u5e74\u6765\uff0c\u6240\u6709\u7684\u4eba\u90fd\u5728\u9519\u8bef\u7684\u4f7f\u7528Http.\u8fd9\u53e5\u8bdd\u600e\u4e48\u8bf4\u5462\uff1f<br \/>\n\u5982\u679c\u8bf4\u4f60\u8981\u5220\u9664\u4e00\u4e2a\u6570\u636e\uff0c\u4ee5\u5f80\u7684\u505a\u6cd5\u901a\u5e38\u662f\u00a0delete\/{id}<br \/>\n\u5982\u679c\u4f60\u8981\u66f4\u65b0\u4e00\u4e2a\u6570\u636e\uff0c\u53ef\u80fd\u662fPost\u6570\u636e\u653eBody\uff0c\u7136\u540e\u65b9\u6cd5\u662f\u00a0update\/{id}\uff0c \u6216\u8005\u662fartichle\/{id}?method=update<br \/>\n\u8fd9\u79cd\u505a\u6cd5\u8ba9Roy Fielding\u5f88\u66b4\u71e5\uff0c\u4ed6\u89c9\u5f97\u8fd9\u4e2a\u4e16\u754c\u4e0d\u8be5\u8fd9\u6837\u7684\uff0c\u6240\u6709\u7684\u4eba\u90fd\u5728\u8bef\u89e3\u800c\u4e14\u5728\u4e25\u91cd\u9519\u8bef\u7684\u8bef\u89e3Http\u7684\u8bbe\u8ba1\u521d\u8877\uff0c\u597d\u6bd4\u662f\u53d1\u660e\u4e86\u706b\u836f\u5374\u53ea\u7528\u5b83\u6765\u505a\u70df\u82b1\u7206\u7af9\u3002<br \/>\n\u90a3\u4e48\u6b63\u786e\u7684\u4f7f\u7528\u65b9\u5f0f\u662f\u4ec0\u4e48\u5462\uff1f\u5982\u679c\u4f60\u8981\u770bRest\u5404\u79cd\u7279\u6027\uff0c\u4f60\u6050\u6015\u771f\u7684\u5f88\u96be\u7406\u89e3Rest\uff0c\u4f46\u662f\u5982\u679c\u4f60\u770b\u9519\u8bef\u7684\u4f7f\u7528http\u7684\u4eba\u5012\u5e95\u513f\u4e86\u54ea\u4e9b\u9519\uff0c\u4ec0\u4e48\u662fRest\u5c31\u7279\u522b\u5bb9\u6613\u7406\u89e3\u4e86\u3002<\/p>\n<p><strong>\u4e03\u5b97\u7f6a\u7684\u7b2c\u4e00\u6761\uff0c\u6df7\u4e71<\/strong>\u3002<\/p>\n<p>\u4e00\u4e07\u4e2a\u4eba\u5fc3\u91cc\u6709\u4e00\u4e07\u4e2aUrl\u7684\u547d\u540d\u89c4\u5219\uff0cUrl\u662f\u7edf\u4e00\u8d44\u6e90\u5b9a\u4f4d\u7b26\uff0c\u91cd\u70b9\u662f\u8d44\u6e90\u3002\u800c\u5f88\u591a\u4eba\u5374\u628a\u5b83\u5f53\u6210\u4e86\u4e07\u91d1\u6cb9\uff0c\u6bcf\u4e00\u4e2a\u72ec\u7acb\u7684\u865a\u62df\u7684\u7f51\u9875\u90fd\u53ef\u4ee5\u968f\u610f\u4f7f\u7528\uff0c\u5404\u79cd\u64cd\u4f5c\u90fd\u80fd\u591f\u8fed\u52a0\u3002\u8fd9\u662f\u6df7\u4e71\u7684\u6765\u6e90\u4e4b\u4e00\u3002<br \/>\n\u6bd4\u5982\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">https:\/\/localhost:8080\/myweb\/getUserById?id=1\r\nhttps:\/\/localhost:8080\/myweb\/user\/getById?id=1\r\nhttps:\/\/localhost:8080\/myweb\/x\/y?id=1<\/pre>\n<p><strong>\u7b2c\u4e8c\u6761\uff0c\u8d2a\u5a6a\u3002<\/strong><\/p>\n<p>\u6709\u72b6\u6001\u548c\u65e0\u72b6\u6001\u5168\u90e8\u6df7\u5728\u4e00\u8d77\u3002\u7279\u522b\u662f\u5728\u8d2d\u7269\u8f66\u6216\u8005\u662f\u767b\u5f55\u7684\u5e94\u7528\u4e2d\uff0c\u7ecf\u5e38\u5237\u65b0\u5c31\u4e22\u5931\u5e26\u6765\u7684\u7528\u6237\u4f53\u9a8c\u7b80\u76f4\u68d2\u68d2\u54d2\u3002\u6bcf\u4e00\u4e2a\u8bf7\u6c42\u5e76\u4e0d\u80fd\u5355\u72ec\u7684\u54cd\u5e94\u4e00\u4e9b\u529f\u80fd\uff0c\u5f88\u591a\u7684\u529f\u80fd\u6df7\u6742\u5728\u4e00\u8d77\u91cc\u3002\u8fd9\u662f\u4eba\u6027\u8d2a\u5a6a\u7684\u672c\u8d28\uff0c\u4e5f\u662f\u5404\u79cdHack\u7684\u8d77\u6e90\uff0c\u53ea\u8981\u80fd\u591f\u628a\u95ee\u9898\u89e3\u51b3\u6389\uff0c\u603b\u4f1a\u6709\u4eba\u7528\u4ed6\u8ba4\u4e3a\u6700\u65b9\u4fbf\u7684\u65b9\u5f0f\u53bb\u89e3\u51b3\u95ee\u9898\uff0c\u6bd4\u5982\u8bf4\u6c7d\u8f66\u95e8\u628a\u624b\u574f\u6389\u4e86\u76f4\u63a5\u7cfb\u6839\u7ef3\u5b50\u5f53\u628a\u624b\uff0cemmmm\u8fd9\u6837\u786e\u5b9e\u5f88\u68d2\u554a\u3002<\/p>\n<p><strong>\u7b2c\u4e09\u6761\uff0c\u65e0\u5e8f\u3002<\/strong><\/p>\n<p>\u8fd4\u56de\u7684\u7ed3\u679c\u5f80\u5f80\u662f\u5f88\u968f\u610f\uff0c\u5404\u79cd\u9519\u8bef\u4fe1\u606f\u672c\u6765\u5c31\u662f\u7528Http\u7684\u72b6\u6001\u7801\u6784\u6210\u7684\uff0c\u53ef\u662f\u5f88\u591a\u4eba\u8fd8\u662f\u559c\u6b22\u628a\u9519\u8bef\u4fe1\u606f\u8fd4\u56de\u5728\u8fd4\u56de\u503c\u4e2d\u3002\u6700\u5e38\u89c1\u7684\u5c31\u662fCode\u548cMessage\uff0c\u5f53\u7136\u5bf9\u4e8e\u8fd9\u4e00\u70b9\uff0c\u6211\u4e2a\u4eba\u662f\u4fdd\u7559\u7591\u95ee\u7684\uff0c\u6211\u7684\u89c2\u70b9\u662f\uff0cHttp\u672c\u8eab\u7684\u9519\u8bef\u548c\u670d\u52a1\u5668\u7684\u5185\u90e8\u9519\u8bef\u8fd8\u662f\u9700\u8981\u5728\u4e0d\u65ad\u5c42\u9762\u5206\u5f00\u7684\uff0c\u4e0d\u80fd\u6df7\u5728\u4e00\u8d77\u3002\u53ef\u662f\u5728\u5927\u795e\u773c\u91cc\u5e76\u975e\u5982\u6b64\u3002<\/p>\n<p><code>\u90a3\u4e48\u600e\u4e48\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u5462\uff1f<\/code><\/p>\n<p>\u5f3a\u8feb\u75c7\u60a3\u8005\u7684\u798f\u97f3\u5c31\u662f<code>\u5148\u9881\u89c4\u5219<\/code>\uff0c<code>\u7b2c\u4e00\u4e2a\u89c4\u5219\u5c31\u662f\u660e\u786eUrl\u662f\u4ec0\u4e48\uff0c\u8be5\u600e\u4e48\u7528<\/code>\u3002\u5c31\u662f\u6240\u6709\u7684<code>Url\u672c\u8d28<\/code>\u6765\u8bb2\uff0c\u90fd\u5e94\u8be5<code>\u662f\u4e00\u79cd\u8d44\u6e90<\/code>\u3002\u4e00\u4e2a\u72ec\u7acb\u7684Url\u5730\u5740\uff0c\u5c31\u662f\u5bf9\u5e94\u4e00\u4e2a\u72ec\u4e00\u65e0\u4e8c\u7684\u8d44\u6e90\u3002\u600e\u4e48\u6837\uff1f\u8fd9\u79cd\u611f\u89c9\u662f\u4e0d\u662f\u68d2\u68d2\u54d2\uff1f\u4e00\u4e2a\u51b0\u6dc7\u6dcb\uff0c\u4e00\u4e2a\u8001\u5e08\uff0c\u4e00\u95f4\u623f\u5b50\uff0c\u5728Url\u4e0a\u5bf9\u5e94\u7684\u90fd\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u4e0d\u4f1a\u6709\u591a\u4f59\u7684Url\u8ddf\u4ed6\u5bf9\u5e94\uff0c\u4e5f\u4e0d\u4f1a\u8868\u793a\u6709\u591a\u4e2aUrl\u5730\u5740<br \/>\n\u6ce8\u610f\uff0c\u8fd9\u91cc\u70b9\u7684\u662fUrl\u5730\u5740\uff0c\u5e76\u4e0d\u662f\u5355\u72ec\u7684\u53c2\u6570\uff0c\u4ed6\u5c31\u662f\u4e00\u4e2a<code>\/room\/{room_id}<\/code>\u8fd9\u6837\u7684\u4e1c\u897f\uff0c\u4e3e\u4e2a\u6817\u5b50,<code>\/room\/3242 \u8fd9\u5c31\u8868\u793a3242\u53f7\u623f\u95f4<\/code>\u3002\u8fd9\u662f\u4e00\u4e2a\u6e05\u723d\u7684\u4e16\u754c\u554a\uff0c\u4f60\u60f3\u60f3\uff0c\u4e4b\u524d\u7684Url\u662f\u4ec0\u4e48\u90fd\u8981\uff0c\u6211\u5f00\u623f\uff0c\u53ef\u80fd\u662f<code>\/open\/room\/3242<\/code>\u00a0\u6211\u8981\u9000\u623f\u53ef\u80fd\u662f<code>\/exit\/3242\/room<\/code>\uff0c\u6211\u8981\u6253\u7406\u623f\u95f4\uff0c\u53ef\u80fd\u662f<code>room\/3242?method=clean.<\/code>\u591f\u4e86\uff01\u8fd9\u4e9b\u4e71\u4e03\u516b\u7cdf\u7684\u4e1c\u897f\u5168\u591f\u4e86\uff0c\u8ba9\u4e16\u754c\u56de\u5f52\u6e05\u723d\u7684\u672c\u8d28\uff0c<code>\u4e00\u95f4\u623f\uff0c\u5c31\u662f\/room\/3242 \u6ca1\u6709\u522b\u7684Url\u5730\u5740\u4e86\u3002<\/code><br \/>\n\u5728\u8fc7\u53bb\u7684\u6df7\u4e71\u4e16\u754c\u91cc\uff0c\u7ecf\u5e38\u7528\u7684\u5c31\u662f<code>Get\u548cPost<\/code>\u3002\u5982\u679c\u4e0d\u662f\u56e0\u4e3aGet\u4e0d\u652f\u6301\u5927\u6570\u636e\u4f20\u8f93\uff0c\u6211\u60f3\u8fdePost\u90fd\u4e0d\u4f1a\u6709\u4eba\u4f7f\u7528\u3002\uff08\u60f3\u50cf\u4e00\u4e0bRoy Fielding\u5728\u6124\u6012\u7684\u5bf9\u7740\u7535\u8111\u5c4f\u5e55\u558a\uff0cHttp\u7684Method\u4e00\u5171\u6709\u516b\u4e2a\uff0c\u4f60\u4eec\u4e3a\u6bdb\u53ea\u902e\u7740Get\u4e00\u53ea\u7f8a\u7684\u6bdb\u8585\u8585\u8585\u8585\u8585\uff09\u3002<\/p>\n<p>\u800c\u5bf9\u8d44\u6e90\u6700\u5e38\u89c1\u7684\u64cd\u4f5c\u662f\u4ec0\u4e48\uff1f<code>CRUD<\/code>\uff0c\u5bf9\u4e0d\u5bf9\uff0c\u5c31\u662f\u521b\u5efa\uff0c\u8bfb\uff0c\u66f4\u65b0\uff0c\u5220\u9664\u3002\u518d\u770bHttp\u7684Method\uff1f\u662f\u4e0d\u662f\u975e\u5e38\u5b8c\u7f8e\uff1f\u5176\u5b9e\u4e5f\u602aFielding\u8001\u7237\u5b50\u4e00\u5f00\u59cb\u547d\u540d\u4e0d\u51c6\u786e\uff0c\u5982\u679c\u521a\u5f00\u59cb\u5c31\u662f\u628a<code>Get\u65b9\u6cd5\u53eb\u505aRead<\/code>\uff0c<code>Put\u65b9\u6cd5\u53eb\u505aUpdate<\/code>\uff0c<code>Post\u53eb\u505aCreate\u8fd9\u8be5\u591a\u597d<\/code>\u3002\u3002\u3002<br \/>\n\u4f60\u7528\u4e00\u4e2aGet\uff0c\u5927\u5bb6\u53c8\u53d1\u73b0\u6ca1\u4ec0\u4e48\u9650\u5236\u6ca1\u4ec0\u4e48\u6240\u8c13\uff0c\u53c8\u5f88\u96be\u7406\u89e3Put\u548cPost\u7684\u5dee\u522b\uff0c\u6cd5\u65e0\u7981\u6b62\u5373\u53ef\u4e3a\u554a\uff0c\u5443\uff0c\u8001\u7237\u5b50\u4e0d\u8981\u77aa\u6211\uff0c\u6211\u778e\u8bf4\u7684\u3002\u603b\u4e4b\uff0c\u8fd9\u56db\u79cd\u65b9\u6cd5\u591f\u4e0d\u591f\u4f60\u6d6a\uff1f\u4f60\u6709\u672c\u8eab\u627e\u51fa\u6765\u66f4\u591a\u7684\u5bf9\u8d44\u6e90\u7684\u64cd\u4f5c\u6765\u554a\uff0c\u6211\u8fd8\u67094\u4e2aMethod\u6ca1\u7528\u8fc7\u5462\u3002\u5982\u679c\u8fd94\u4e2a\u771f\u7684\u4e0d\u591f\u4e86\uff0c\u6709\u4ec0\u4e48\u95ee\u9898\uff0c\u5927\u4e0d\u4e86\u6211\u518d\u91cd\u65b0\u66f4\u6539http\u534f\u8bae\u554a\u3002\u5176\u5b9e\u7b80\u5355\u8bf4\uff0c\u5bf9\u4e8eRest\u7406\u89e3\u5230\u8fd9\u91cc\u5c31\u591f\u4e86\u3002\u540e\u7eed\u7684\u4e1c\u897f\uff0c\u90fd\u662f\u5728\u8fd9\u4e00\u6761\u57fa\u7840\u4e0a\u7a7a\u60f3\u51fa\u6765\u7684\uff0c\u6bd4\u5f3a\u8feb\u75c7\u66f4\u5f3a\u8feb\u75c7\uff0c\u5f53\u7136\uff0c\u65e0\u72b6\u6001\u6211\u662f\u767e\u5206\u767e\u652f\u6301\u7684\u3002\u4ee5\u4e0a\u7684\u5404\u79cd\u8868\u8ff0\u53ef\u80fd\u4e0d\u592a\u51c6\u786e\uff0c\u4e5f\u7eaf\u5c5e\u662f\u6211\u7684\u610f\u6deb\u548c\u5404\u79cd\u5c0f\u9053\u8d44\u6599\uff0c\u5e76\u672a\u8003\u636e\uff0c\u4f46\u662f\u51ed\u826f\u5fc3\u8bb2\uff0c\u6211\u662f\u65e9\u5c31\u770b\u4e0d\u60ef\u9ed1\u6697\u5e74\u4ee3\u91cc\u7684Url\u547d\u540d\u98ce\u683c\u4e86\uff0c\u6240\u4ee5\u5f53\u65f6\u6700\u65e9\u63a5\u89e6\u5230Rest\u7684\u65f6\u5019\uff0c\u77ac\u95f4\u5c31\u627e\u5230\u4e86\u771f\u7231\uff0c\u6211\u9760\uff0c\u8fd9\u4e0d\u5c31\u662f\u6211\u4e00\u76f4\u60f3\u8981\u7684\u7b54\u6848\u5417\uff1f<code>\u4f46\u662f\u6211\u4e00\u76f4\u60f3\u7684\u4ec5\u4ec5\u662f\u547d\u540d\u89c4\u8303\uff0c\u4ece\u6765\u6ca1\u6709\u628a\u81ea\u5df1\u7684\u601d\u8003\u89d2\u5ea6\u653e\u5728\u4e00\u4e2aurl\u5c31\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u6240\u6709\u7684\u64cd\u4f5c\u90fd\u662f\u5bf9\u8d44\u6e90\u7684\u66f4\u6539\u800c\u8a00\u7684\u89d2\u5ea6\u4e0a\u554a\u3002<\/code>\u6240\u4ee5\u4f60\u80fd\u7406\u89e3\u5230\u7684\u7a0b\u5ea6\uff0c\u66f4\u591a\u7684\u5c31\u662f\u5728\u4e8e\u4f60\u8981\u5f04\u6e05\u695a\u4f60\u8981\u89e3\u51b3\u7684\u4ec0\u4e48\u95ee\u9898\uff0c\u5982\u679c\u4f60\u7684\u95ee\u9898\u53ea\u662f\u7406\u89e3Rest\uff0c\u6050\u6015\u4f60\u5f88\u7406\u89e3\uff0c\u5982\u679c\u4f60\u7684\u95ee\u9898\u662f\u600e\u4e48\u89e3\u51b3Url\u6df7\u4e71\u7684\u95ee\u9898\uff0c\u4f60\u53cd\u800c\u5f88\u5feb\u80fd\u5f04\u61c2\u4e86~<\/p>\n<h1 id=\"\u5bf9\u6bd4\">\u5bf9\u6bd4<\/h1>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">https:\/\/localhost:8080\/myweb\/getDogs --&gt; GET \/rest\/api\/dogs \u83b7\u53d6\u6240\u6709\u5c0f\u72d7\u72d7 \r\nhttps:\/\/localhost:8080\/myweb\/addDogs --&gt; POST \/rest\/api\/dogs \u6dfb\u52a0\u4e00\u4e2a\u5c0f\u72d7\u72d7 \r\nhttps:\/\/localhost:8080\/myweb\/updateDogs\/:dog_id --&gt; PUT \/rest\/api\/dogs\/:dog_id \u4fee\u6539\u4e00\u4e2a\u5c0f\u72d7\u72d7 \r\nhttps:\/\/localhost:8080\/myweb\/deleteDogs\/:dog_id --&gt; DELETE \/rest\/api\/dogs\/:dog_id \u5220\u9664\u4e00\u4e2a\u5c0f\u72d7\u72d7<\/pre>\n<p>\u5de6\u8fb9\u662f\u6211\u4eec\u5199\u7684\uff0c\u800c\u4e14\u540e\u53f0\u6211\u4eec\u53ef\u80fd\u4f1a\u5199\u51fa\u5f88\u591a\u8fd4\u56de\u503c\uff0c\u800c\u4e14\u5404\u79cd\u5404\u6837\u7684\uff0c\u6bd4\u5982<br \/>\n<a href=\"https:\/\/localhost:8080\/myweb\/addDogs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/localhost:8080\/myweb\/addDogs<\/a><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\u64cd\u4f5c\u6210\u529f \u6216\u8005 1<\/pre>\n<p>\u6216\u8005<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">\u64cd\u4f5c\u5931\u8d25 \u6216\u8005 0<\/pre>\n<p>\u8fd9\u8fd8\u8981\u6211\u4eec\u81ea\u5df1\u53bb\u89e3\u6790\uff0c\u8fd8\u8981\u524d\u7aef\u548c\u540e\u7aef\u53bb\u534f\u5546\u4f60\u8fd4\u56de\u76840\u662f\u5565\u610f\u8bc6\u554a\u3002\u4f46\u662fREST\u8fd4\u56de\u503c\u662f\u6807\u51c6\u7684\uff0c\u6bd4\u5982<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">HTTP\/1.1 200 OK\r\nContent-Type: application\/json\r\nContent-Length: xxx\r\n\r\n{\r\n   \"url\" : \"\/api\/categories\/1\",\r\n   \"label\" : \"Food\",\r\n   \"items_url\" : \"\/api\/items?category=1\",\r\n   \"brands\" : [\r\n         {\r\n            \"label\" : \"\u53cb\u81e3\",\r\n            \"brand_key\" : \"32073\",\r\n            \"url\" : \"\/api\/brands\/32073\"\r\n         }, {\r\n            \"label\" : \"\u4e50\u4e8b\",\r\n            \"brand_key\" : \"56632\",\r\n            \"url\" : \"\/api\/brands\/56632\"\r\n         }\r\n         ...\r\n   ]\r\n}<\/pre>\n<p><code>\u683c\u5f0f\u56fa\u5b9a\uff0c\u7b2c\u4e00\u884c\u6c38\u8fdc\u662f\u64cd\u4f5c\u5931\u8d25\u6216\u8005\u6210\u529f\u7684\u72b6\u6001\u7801\uff0c\u7b2c\u4e8c\u884c\u662f\u8fd4\u56de\u7684\u7c7b\u578b\uff0c\u7b2c\u4e09\u884c\u5185\u5bb9\u7684\u957f\u5ea6\uff0c\u7b2c\u4e94\u884c\u5f00\u59cb\u662f\u5185\u5bb9\u3002<\/code><\/p>\n<p><code>\u8fd9\u6837\u6211\u53ea\u9700\u5199\u4e00\u4e2a\u7a0b\u5e8f\u89e3\u6790\u8fd4\u56de\u7684\u4fe1\u606f\u5c31\u53ef\u4ee5\u4e86\uff0c\u53ef\u4ee5\u91cd\u7528\uff0c\u4f46\u662f\u6211\u4eec\u4e0a\u9762\u4f20\u7edf\u7684\u4e0d\u4ec5\u4ec5\u8981\u534f\u5546\uff0c\u8fd8\u6709\u6709\u4e0d\u540c\u7684\u89e3\u6790\u7a0b\u5e8f\uff0c\u7a0d\u5fae\u6539\u53d8\uff0c\u5c31\u4e0d\u80fd\u6b63\u5e38\u4f7f\u7528\u4e86\u3002\u6240\u4ee5rest\u7684\u660e\u663e\u66f4\u52a0\u901a\u7528\u3002<\/code><\/p>\n<p>\u5217\u5b502<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">1\u3001\u83b7\u53d6\u6587\u7ae0\r\n\r\n\u8bf7\u6c42\uff1a\r\nGET \/blog\/post\/{postId} HTTP\/1.1\r\n\r\n\u54cd\u5e94\uff1a\r\nHTTP\/1.1 200 OK\r\n{\r\n    \"title\": \"foobar\",\r\n    \"content\": \"foobar\",\r\n    \"comments\": [\"\", \"\", \"\"]\r\n}\r\n\r\n2\u3001\u53d1\u5e03\u6587\u7ae0\r\n\r\n\u8bf7\u6c42\uff1a\r\nPOST \/blog\/post HTTP\/1.1\r\n{\r\n    \"title\": \"foobar\",\r\n    \"content\": \"foobar\",\r\n    \"comments\": [\"\", \"\", \"\"]\r\n}\r\n\r\n\u54cd\u5e94\uff1a\r\nHTTP\/1.1 201 CREATED<\/pre>\n<h1 id=\"\u89c4\u5219\">\u89c4\u5219<\/h1>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">GET    \u7528\u6765\u83b7\u53d6\u8d44\u6e90\uff0c\r\nPOST  \u7528\u6765\u65b0\u5efa\u8d44\u6e90\uff08\u4e5f\u53ef\u4ee5\u7528\u4e8e\u66f4\u65b0\u8d44\u6e90\uff09\uff0c\r\nPUT    \u7528\u6765\u66f4\u65b0\u8d44\u6e90\uff0c\r\nDELETE  \u7528\u6765\u5220\u9664\u8d44\u6e90<\/pre>\n<p>\u4f8b\u5b50<\/p>\n<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">DELETE http:\/\/api.qc.com\/v1\/friends: \u5220\u9664\u67d0\u4eba\u7684\u597d\u53cb \uff08\u5728http parameter\u6307\u5b9a\u597d\u53cbid\uff09\r\nPOST http:\/\/api.qc.com\/v1\/friends: \u6dfb\u52a0\u597d\u53cbUPDATE \r\nhttp:\/\/api.qc.com\/v1\/profile: \u66f4\u65b0\u4e2a\u4eba\u8d44\u6599<\/pre>\n<div id=\"content_views\" class=\"markdown_views\">\n<h1 id=\"\u6982\u5ff5\">\u6982\u5ff5<\/h1>\n<p><strong><code>REST \u662f\u9762\u5411\u8d44\u6e90\u7684\uff0c\u8fd9\u4e2a\u6982\u5ff5\u975e\u5e38\u91cd\u8981\uff0c\u800c\u8d44\u6e90\u662f\u901a\u8fc7 URI \u8fdb\u884c\u66b4\u9732\u3002<\/code><\/strong><br \/>\nURI \u7684\u8bbe\u8ba1\u53ea\u8981\u8d1f\u8d23\u628a\u8d44\u6e90\u901a\u8fc7\u5408\u7406\u65b9\u5f0f\u66b4\u9732\u51fa\u6765\u5c31\u53ef\u4ee5\u4e86\u3002\u5bf9\u8d44\u6e90\u7684\u64cd\u4f5c\u4e0e\u5b83\u65e0\u5173\uff0c\u64cd\u4f5c\u662f\u901a\u8fc7 HTTP\u52a8\u8bcd\u6765\u4f53\u73b0\uff0c\u6240\u4ee5REST \u901a\u8fc7 URI \u66b4\u9732\u8d44\u6e90\u65f6\uff0c\u4f1a\u5f3a\u8c03\u4e0d\u8981\u5728 URI \u4e2d\u51fa\u73b0\u52a8\u8bcd\u3002<\/p>\n<p>\u6bd4\u5982\uff1a\u5de6\u8fb9\u662f\u9519\u8bef\u7684\u8bbe\u8ba1\uff0c\u800c\u53f3\u8fb9\u662f\u6b63\u786e\u7684<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">GET \/rest\/api\/getDogs --&gt; GET \/rest\/api\/dogs \u83b7\u53d6\u6240\u6709\u5c0f\u72d7\u72d7 \r\nGET \/rest\/api\/addDogs --&gt; POST \/rest\/api\/dogs \u6dfb\u52a0\u4e00\u4e2a\u5c0f\u72d7\u72d7 \r\nGET \/rest\/api\/editDogs\/:dog_id --&gt; PUT \/rest\/api\/dogs\/:dog_id \u4fee\u6539\u4e00\u4e2a\u5c0f\u72d7\u72d7 \r\nGET \/rest\/api\/deleteDogs\/:dog_id --&gt; DELETE \/rest\/api\/dogs\/:dog_id \u5220\u9664\u4e00\u4e2a\u5c0f\u72d7\u72d7<\/pre>\n<p><strong><code>REST\u5f88\u597d\u5730\u5229\u7528\u4e86HTTP\u672c\u8eab\u5c31\u6709\u7684\u4e00\u4e9b\u7279\u5f81\uff0c\u5982HTTP\u52a8\u8bcd\u3001HTTP\u72b6\u6001\u7801\u3001HTTP\u62a5\u5934\u7b49\u7b49<\/code><\/strong><br \/>\nREST API \u662f\u57fa\u4e8e HTTP\u7684\uff0c\u6240\u4ee5\u4f60\u7684API\u5e94\u8be5\u53bb\u4f7f\u7528 HTTP\u7684\u4e00\u4e9b\u6807\u51c6\u3002\u8fd9\u6837\u6240\u6709\u7684HTTP\u5ba2\u6237\u7aef\uff08\u5982\u6d4f\u89c8\u5668\uff09\u624d\u80fd\u591f\u76f4\u63a5\u7406\u89e3\u4f60\u7684API\uff08\u5f53\u7136\u8fd8\u6709\u5176\u4ed6\u597d\u5904\uff0c\u5982\u5229\u4e8e\u7f13\u5b58\u7b49\u7b49\uff09\u3002REST \u5b9e\u9645\u4e0a\u4e5f\u975e\u5e38\u5f3a\u8c03\u5e94\u8be5\u5229\u7528\u597d HTTP\u672c\u6765\u5c31\u6709\u7684\u7279\u5f81\uff0c\u800c\u4e0d\u662f\u53ea\u628a HTTP\u5f53\u6210\u4e00\u4e2a\u4f20\u8f93\u5c42\u8fd9\u4e48\u7b80\u5355\u4e86\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">HTTP\/1.1 200 OK\r\nContent-Type: application\/json\r\nContent-Length: xxx\r\n\r\n{\r\n   \"url\" : \"\/api\/categories\/1\",\r\n   \"label\" : \"Food\",\r\n   \"items_url\" : \"\/api\/items?category=1\",\r\n   \"brands\" : [\r\n         {\r\n            \"label\" : \"\u53cb\u81e3\",\r\n            \"brand_key\" : \"32073\",\r\n            \"url\" : \"\/api\/brands\/32073\"\r\n         }, {\r\n            \"label\" : \"\u4e50\u4e8b\",\r\n            \"brand_key\" : \"56632\",\r\n            \"url\" : \"\/api\/brands\/56632\"\r\n         }\r\n         ...\r\n   ]\r\n}<\/pre>\n<p>\u770b\u8fd9\u4e2a\u54cd\u5e94\uff0c\u5305\u542b\u4e86http\u91cc\u9762\u7684\u72b6\u6001\u7801\u7b49\u4fe1\u606f\u3002\u8fd8\u4f1a\u6709http\u7684\u4e00\u4e9b\u62a5\u5934\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Authorization \u8ba4\u8bc1\u62a5\u5934 \r\nCache-Control \u7f13\u5b58\u62a5\u5934 \r\nCnotent-Type  \u6d88\u606f\u4f53\u7c7b\u578b\u62a5\u5934 \r\n......<\/pre>\n<h1 id=\"rest-\u7cfb\u7edf\u7684\u7279\u5f81\">REST \u7cfb\u7edf\u7684\u7279\u5f81<\/h1>\n<ol>\n<li><strong><code>\u5ba2\u6237-\u670d\u52a1\u5668\uff08Client-Server\uff09<\/code><\/strong>\uff0c\u63d0\u4f9b\u670d\u52a1\u7684\u670d\u52a1\u5668\u548c\u4f7f\u7528\u670d\u52a1\u7684\u5ba2\u6237\u9700\u8981\u88ab\u9694\u79bb\u5bf9\u5f85\u3002<\/li>\n<li><strong><code>\u65e0\u72b6\u6001\uff08Stateless\uff09<\/code><\/strong>\uff0c<code>\u6765\u81ea\u5ba2\u6237\u7684\u6bcf\u4e00\u4e2a\u8bf7\u6c42\u5fc5\u987b\u5305\u542b\u670d\u52a1\u5668\u5904\u7406\u8be5\u8bf7\u6c42\u6240\u9700\u7684\u6240\u6709\u4fe1\u606f<\/code>\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u670d\u52a1\u5668\u7aef\u4e0d\u80fd\u5b58\u50a8\u6765\u81ea\u67d0\u4e2a\u5ba2\u6237\u7684\u67d0\u4e2a\u8bf7\u6c42\u4e2d\u7684\u4fe1\u606f\uff0c\u5e76\u5728\u8be5\u5ba2\u6237\u7684\u5176\u4ed6\u8bf7\u6c42\u4e2d\u4f7f\u7528\u3002<\/li>\n<li><strong><code>\u53ef\u7f13\u5b58\uff08Cachable\uff09<\/code><\/strong>\uff0c\u670d\u52a1\u5668\u5fc5\u987b\u8ba9\u5ba2\u6237\u77e5\u9053\u8bf7\u6c42\u662f\u5426\u53ef\u4ee5\u88ab\u7f13\u5b58\u3002\uff08Ross\uff1a\u66f4\u8be6\u7ec6\u89e3\u91ca\u8bf7\u53c2\u8003 \u7406\u89e3\u672c\u771f\u7684REST\u67b6\u6784\u98ce\u683c \u4ee5\u53ca StackOverflow \u7684\u8fd9\u4e2a\u95ee\u9898 \u4e2d\u5bf9\u7f13\u5b58\u7684\u89e3\u91ca\u3002\uff09<\/li>\n<li><strong><code>\u5206\u5c42\u7cfb\u7edf\uff08Layered System\uff09<\/code><\/strong>\uff0c\u670d\u52a1\u5668\u548c\u5ba2\u6237\u4e4b\u95f4\u7684\u901a\u4fe1\u5fc5\u987b\u88ab\u8fd9\u6837\u6807\u51c6\u5316\uff1a\u5141\u8bb8\u670d\u52a1\u5668\u548c\u5ba2\u6237\u4e4b\u95f4\u7684\u4e2d\u95f4\u5c42\uff08Ross\uff1a\u4ee3\u7406\uff0c\u7f51\u5173\u7b49\uff09\u53ef\u4ee5\u4ee3\u66ff\u670d\u52a1\u5668\u5bf9\u5ba2\u6237\u7684\u8bf7\u6c42\u8fdb\u884c\u56de\u5e94\uff0c\u800c\u4e14\u8fd9\u4e9b\u5bf9\u5ba2\u6237\u6765\u8bf4\u4e0d\u9700\u8981\u7279\u522b\u652f\u6301\u3002<\/li>\n<li><strong><code>\u7edf\u4e00\u63a5\u53e3\uff08Uniform Interface\uff09<\/code><\/strong>\uff0c\u5ba2\u6237\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u901a\u4fe1\u7684\u65b9\u6cd5\u5fc5\u987b\u662f\u7edf\u4e00\u5316\u7684\u3002\uff08Ross\uff1aGET,POST,PUT.DELETE, etc\uff09<\/li>\n<li><strong><code>\u652f\u6301\u6309\u9700\u4ee3\u7801\uff08Code-On-Demand\uff0c\u53ef\u9009\uff09<\/code><\/strong>\uff0c\u670d\u52a1\u5668\u53ef\u4ee5\u63d0\u4f9b\u4e00\u4e9b\u4ee3\u7801\u6216\u8005\u811a\u672c\uff08Ross\uff1aJavascrpt\uff0cflash\uff0cetc\uff09\u5e76\u5728\u5ba2\u6237\u7684\u8fd0\u884c\u73af\u5883\u4e2d\u6267\u884c\u3002\u8fd9\u6761\u51c6\u5219\u662f\u8fd9\u4e9b\u51c6\u5219\u4e2d\u552f\u4e00\u4e0d\u5fc5\u5fc5\u987b\u6ee1\u8db3\u7684\u4e00\u6761\u3002\uff08Ross\uff1a\u6bd4\u5982\u5ba2\u6237\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u4e0b\u8f7d\u811a\u672c\u751f\u6210\u5bc6\u7801\u8bbf\u95ee\u670d\u52a1\u5668\u3002\uff09<\/li>\n<\/ol>\n<p><strong>\u8be6\u7ec6\u89e3\u91ca<\/strong><\/p>\n<p><strong><code>\u65e0\u72b6\u6001\uff08Stateless\uff09<\/code><\/strong><\/p>\n<p>\u6240\u8c13\u65e0\u72b6\u6001\u7684\uff0c\u5373\u6240\u6709\u7684\u8d44\u6e90\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7URI\u5b9a\u4f4d\uff0c\u800c\u4e14\u8fd9\u4e2a\u5b9a\u4f4d\u4e0e\u5176\u4ed6\u8d44\u6e90\u65e0\u5173\uff0c\u4e5f\u4e0d\u4f1a\u56e0\u4e3a\u5176\u4ed6\u8d44\u6e90\u7684\u53d8\u5316\u800c\u6539\u53d8\u3002\u6709\u72b6\u6001\u548c\u65e0\u72b6\u6001\u7684\u533a\u522b\uff0c\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u8bf4\u660e\u4e00\u4e0b\u3002\u5982\u67e5\u8be2\u5458\u5de5\u7684\u5de5\u8d44\uff0c\u5982\u679c\u67e5\u8be2\u5de5\u8d44\u662f\u9700\u8981\u767b\u5f55\u7cfb\u7edf\uff0c\u8fdb\u5165\u67e5\u8be2\u5de5\u8d44\u7684\u9875\u9762\uff0c\u6267\u884c\u76f8\u5173\u64cd\u4f5c\u540e\uff0c\u83b7\u53d6\u5de5\u8d44\u7684\u591a\u5c11\uff0c\u5219\u8fd9\u79cd\u60c5\u51b5\u662f\u6709\u72b6\u6001\u7684\uff0c<code>\u56e0\u4e3a\u67e5\u8be2\u5de5\u8d44\u7684\u6bcf\u4e00\u6b65\u64cd\u4f5c\u90fd\u4f9d\u8d56\u4e8e\u524d\u4e00\u6b65\u64cd\u4f5c\uff0c\u53ea\u8981\u524d\u7f6e\u64cd\u4f5c\u4e0d\u6210\u529f\uff0c\u540e\u7eed\u64cd\u4f5c\u5c31\u65e0\u6cd5\u6267\u884c\uff1b<\/code>\u5982\u679c\u8f93\u5165\u4e00\u4e2aurl\u5373\u53ef\u5f97\u5230\u6307\u5b9a\u5458\u5de5\u7684\u5de5\u8d44\uff0c\u5219\u8fd9\u79cd\u60c5\u51b5\u662f\u65e0\u72b6\u6001\u7684\uff0c\u56e0\u4e3a\u83b7\u53d6\u5de5\u8d44\u4e0d\u4f9d\u8d56\u4e8e\u5176\u4ed6\u8d44\u6e90\u6216\u72b6\u6001\uff0c\u4e14\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5458\u5de5\u5de5\u8d44\u662f\u4e00\u4e2a\u8d44\u6e90\uff0c\u7531\u4e00\u4e2aurl\u4e0e\u4e4b\u5bf9\u5e94\uff0c\u53ef\u4ee5\u901a\u8fc7HTTP\u4e2d\u7684GET\u65b9\u6cd5\u5f97\u5230\u8d44\u6e90\uff0c\u8fd9\u662f\u5178\u578b\u7684RESTful\u98ce\u683c\u3002<\/p>\n<p><img decoding=\"async\" title=\"\" src=\"https:\/\/img-blog.csdn.net\/20180421191940578?watermark\/2\/text\/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMzgzNDM1\/font\/5a6L5L2T\/fontsize\/400\/fill\/I0JBQkFCMA==\/dissolve\/70\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" title=\"\" src=\"https:\/\/img-blog.csdn.net\/20180421191951608?watermark\/2\/text\/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzIxMzgzNDM1\/font\/5a6L5L2T\/fontsize\/400\/fill\/I0JBQkFCMA==\/dissolve\/70\" alt=\"\u8fd9\u91cc\u5199\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><strong><code>\u7edf\u4e00\u63a5\u53e3\uff08Uniform Interface\uff09<\/code><\/strong><\/p>\n<p>RESTful\u67b6\u6784\u98ce\u683c\u89c4\u5b9a\uff0c\u6570\u636e\u7684\u5143\u64cd\u4f5c\uff0c\u5373CRUD(create, read, update\u548cdelete,\u5373\u6570\u636e\u7684\u589e\u5220\u67e5\u6539)\u64cd\u4f5c\uff0c\u5206\u522b\u5bf9\u5e94\u4e8eHTTP\u65b9\u6cd5\uff1aGET\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\uff0c\u8fd9\u6837\u5c31\u7edf\u4e00\u4e86\u6570\u636e\u64cd\u4f5c\u7684\u63a5\u53e3\uff0c\u4ec5\u901a\u8fc7HTTP\u65b9\u6cd5\uff0c\u5c31\u53ef\u4ee5\u5b8c\u6210\u5bf9\u6570\u636e\u7684\u6240\u6709\u589e\u5220\u67e5\u6539\u5de5\u4f5c\u3002<\/p>\n<p>\u5373\uff1a<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">GET\uff08SELECT\uff09\uff1a\u4ece\u670d\u52a1\u5668\u53d6\u51fa\u8d44\u6e90\uff08\u4e00\u9879\u6216\u591a\u9879\uff09\u3002\r\nPOST\uff08CREATE\uff09\uff1a\u5728\u670d\u52a1\u5668\u65b0\u5efa\u4e00\u4e2a\u8d44\u6e90\u3002\r\nPUT\uff08UPDATE\uff09\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u5b8c\u6574\u8d44\u6e90\u6570\u636e\uff09\u3002\r\nPATCH\uff08UPDATE\uff09\uff1a\u5728\u670d\u52a1\u5668\u66f4\u65b0\u8d44\u6e90\uff08\u5ba2\u6237\u7aef\u63d0\u4f9b\u9700\u8981\u4fee\u6539\u7684\u8d44\u6e90\u6570\u636e\uff09\u3002\r\nDELETE\uff08DELETE\uff09\uff1a\u4ece\u670d\u52a1\u5668\u5220\u9664\u8d44\u6e90\u3002<\/pre>\n<h1 id=\"\u6f14\u5316\">\u6f14\u5316<\/h1>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/30396391?group_id=937244108725641216\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/zhuanlan.zhihu.com\/p\/30396391?group_id=937244108725641216<\/a><\/p>\n<h1 id=\"\u4f18\u70b9\u7f3a\u70b9\">\u4f18\u70b9&amp;\u7f3a\u70b9<\/h1>\n<p><code>\u4f18\u70b9<\/code>\u662f\u56e0\u4e3a\u4ed6\u5bf9uri\u8fdb\u884c\u4e86\u9650\u5236\uff0c\u53ea\u7528\u4e8e\u5b9a\u4e49\u8d44\u6e90\u3002\u8fd9\u6837\u770b\u8d77\u6765\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\u3002\u5c24\u5176\u662f\u5bf9\u7b80\u5355\u7684\u5bf9\u8c61\u7684\u589e\u5220\u6539\u67e5\uff0c\u5f88\u597d\u7406\u89e3\u3002<\/p>\n<p><code>\u7f3a\u70b9<\/code>\u662f\u56e0\u4e3a\u8fd9\u79cd\u9650\u5236\uff0c\u5bfc\u81f4\u8bbe\u8ba1uri\u53d8\u5f97\u590d\u6742\u4e86\u3002\u5c24\u5176\u662f\u590d\u6742\u7684\u5173\u7cfb\uff0c\u64cd\u4f5c\uff0c\u8d44\u6e90\u96c6\u5408\uff0c<code>\u786c\u6027\u5957\u7528rest\u539f\u5219\u8bbe\u8ba1\u975e\u5e38\u56f0\u96be<\/code>\u3002\u5728rest\u57fa\u7840\u4e0a\u7684HATEOAS\uff0c\u8fd4\u56de\u7684json\u91cc\u589e\u52a0\u4e86\u76f8\u5e94\u7684\u5173\u7cfb\u548curl\u3002\u8fd9\u4e5f\u540c\u6837\u5e26\u6765\u95ee\u9898\u3002\u597d\u5904\u662f\u5bf9\u7b80\u5355\u7684\u5173\u7cfb\uff0c\u7684\u786e\u53ef\u4ee5\u901a\u8fc7url\u8fdb\u4e00\u6b65\u5904\u7406\u3002\u4f46\u5bf9\u590d\u6742\u7684\u5173\u7cfb\u548c\u64cd\u4f5c\uff0cHATEOAS\u5e76\u4e0d\u80fd\u80dc\u4efb\u63cf\u8ff0\u3002<code>\u53cd\u800c\u5728\u5355\u7eaf\u7684\u6570\u636e\u4e2d\u589e\u52a0\u4e86\u4e00\u5806\u5783\u573e\u4fe1\u606f\u3002<\/code><\/p>\n<h1 id=\"\u662f\u4ec0\u4e48\">\u662f\u4ec0\u4e48\uff1f<\/h1>\n<p>REST\u662f\u4e00\u4e2a<code>\u6807\u51c6\uff0c\u4e00\u79cd\u89c4\u8303<\/code>\uff0c\u9075\u5faaREST\u98ce\u683c\u53ef\u4ee5\u4f7f\u5f00\u53d1\u7684\u63a5\u53e3\u901a\u7528\uff0c\u4fbf\u4e8e\u8c03\u7528\u8005\u7406\u89e3\u63a5\u53e3\u7684\u4f5c\u7528\u3002<\/p>\n<p>\u53c2\u8003\uff1a<br \/>\n<a href=\"https:\/\/www.zhihu.com\/question\/28557115\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/www.zhihu.com\/question\/28557115<\/a><br \/>\n<a href=\"https:\/\/blog.igevin.info\/posts\/restful-architecture-in-general\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/blog.igevin.info\/posts\/restful-architecture-in-general\/<\/a><\/p>\n<\/div>\n<\/div>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>1.\u4f20\u7edf\u4e0b\u7684API\u63a5\u53e3 \u5bf9\u6bd4 \u89c4\u5219 \u6982\u5ff5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[119],"class_list":["post-3080","post","type-post","status-publish","format-standard","hentry","tag-03-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3080","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=3080"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/3080\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=3080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=3080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=3080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}