{"id":8951,"date":"2023-11-28T20:48:23","date_gmt":"2023-11-28T12:48:23","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8951"},"modified":"2023-12-06T16:10:37","modified_gmt":"2023-12-06T08:10:37","slug":"springcloud-zhong-shen-me-shi-fu-wu-qi-wang-guanga","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springcloud-zhong-shen-me-shi-fu-wu-qi-wang-guanga\/","title":{"rendered":"SpringCloud\u4e2d\u4ec0\u4e48\u662f\u670d\u52a1\u5668\u7f51\u5173Gateway,\u4f60\u662f\u5982\u4f55\u7406\u89e3\u7684\uff1f"},"content":{"rendered":"<p>\u5728Spring Cloud\u4e2d\uff0cSpring Cloud Gateway\u662f\u4e00\u4e2a\u5168\u65b0\u7684\u57fa\u4e8eSpring Framework 5\u3001Project Reactor\u548cSpring Boot 2\u7684\u53cd\u5e94\u5f0f\u7f16\u7a0b\u652f\u6301\u7684API\u7f51\u5173\u3002\u5b83\u65e8\u5728\u63d0\u4f9b\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u65b9\u5f0f\u6765\u8fdb\u884c\u8def\u7531\u3001\u8fc7\u6ee4\u548c\u5904\u7406\u8bf7\u6c42\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5bf9Spring Cloud Gateway\u7684\u4e3b\u8981\u6982\u5ff5\u548c\u7406\u89e3\uff1a<\/p>\n<ol>\n<li>\n<strong>API\u7f51\u5173\uff1a<\/strong> Spring Cloud Gateway\u4f5c\u4e3a\u4e00\u4e2aAPI\u7f51\u5173\uff0c\u5145\u5f53\u4e86\u5fae\u670d\u52a1\u4f53\u7cfb\u7ed3\u6784\u7684\u5165\u53e3\u70b9\u3002\u5b83\u8d1f\u8d23\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u5e76\u901a\u8fc7\u4e00\u7cfb\u5217\u8fc7\u6ee4\u5668\u6267\u884c\u9884\u5b9a\u4e49\u7684\u64cd\u4f5c\uff0c\u5982\u8def\u7531\u3001\u8eab\u4efd\u9a8c\u8bc1\u3001\u65e5\u5fd7\u8bb0\u5f55\u7b49\u3002\n<\/li>\n<li>\n<strong>\u53cd\u5e94\u5f0f\u7f16\u7a0b\uff1a<\/strong> Spring Cloud Gateway\u91c7\u7528\u4e86\u53cd\u5e94\u5f0f\u7f16\u7a0b\u6a21\u578b\uff0c\u57fa\u4e8eProject Reactor\u5e93\uff0c\u4f7f\u5f97\u5b83\u80fd\u591f\u4ee5\u5f02\u6b65\u548c\u975e\u963b\u585e\u7684\u65b9\u5f0f\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8bf7\u6c42\u3002\u8fd9\u6709\u52a9\u4e8e\u63d0\u9ad8\u7cfb\u7edf\u7684\u6027\u80fd\u548c\u53ef\u4f38\u7f29\u6027\u3002\n<\/li>\n<li>\n<strong>\u8def\u7531\uff1a<\/strong> Spring Cloud Gateway\u53ef\u4ee5\u6839\u636e\u8def\u7531\u89c4\u5219\u5c06\u8bf7\u6c42\u5b9a\u5411\u5230\u76f8\u5e94\u7684\u5fae\u670d\u52a1\u5b9e\u4f8b\u3002\u8def\u7531\u89c4\u5219\u5b9a\u4e49\u4e86\u8bf7\u6c42\u7684\u5339\u914d\u6761\u4ef6\u548c\u76ee\u6807\u670d\u52a1\u7684\u5730\u5740\uff0c\u4f7f\u5f97\u7f51\u5173\u80fd\u591f\u52a8\u6001\u5730\u5c06\u8bf7\u6c42\u8f6c\u53d1\u5230\u540e\u7aef\u7684\u4e0d\u540c\u670d\u52a1\u3002\n<\/li>\n<li>\n<strong>\u8fc7\u6ee4\u5668\uff1a<\/strong> \u8fc7\u6ee4\u5668\u662fSpring Cloud Gateway\u7684\u6838\u5fc3\u529f\u80fd\u4e4b\u4e00\uff0c\u5b83\u4eec\u5141\u8bb8\u5728\u8bf7\u6c42\u88ab\u8def\u7531\u4e4b\u524d\u6216\u4e4b\u540e\u6267\u884c\u903b\u8f91\u3002\u8fc7\u6ee4\u5668\u53ef\u4ee5\u7528\u4e8e\u5b9e\u73b0\u8ba4\u8bc1\u3001\u9274\u6743\u3001\u8bf7\u6c42\u8f6c\u6362\u3001\u8bf7\u6c42\u65e5\u5fd7\u8bb0\u5f55\u7b49\u529f\u80fd\uff0c\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u6269\u5c55\u6027\u3002\n<\/li>\n<li>\n<strong>\u96c6\u6210\u6027\uff1a<\/strong> Spring Cloud Gateway\u53ef\u4ee5\u4e0e\u5176\u4ed6Spring Cloud\u7ec4\u4ef6\u65e0\u7f1d\u96c6\u6210\uff0c\u5982Eureka\u3001Consul\u3001Ribbon\u7b49\uff0c\u4ee5\u5b9e\u73b0\u670d\u52a1\u6ce8\u518c\u3001\u53d1\u73b0\u548c\u8d1f\u8f7d\u5747\u8861\u3002\n<\/li>\n<li>\n<strong>\u52a8\u6001\u8def\u7531\uff1a<\/strong> Spring Cloud Gateway\u652f\u6301\u52a8\u6001\u8def\u7531\uff0c\u5141\u8bb8\u5728\u8fd0\u884c\u65f6\u52a8\u6001\u5730\u6dfb\u52a0\u3001\u4fee\u6539\u548c\u5220\u9664\u8def\u7531\u89c4\u5219\u3002\u8fd9\u79cd\u7075\u6d3b\u6027\u4f7f\u5f97\u7cfb\u7edf\u80fd\u591f\u66f4\u597d\u5730\u5e94\u5bf9\u53d8\u5316\u548c\u52a8\u6001\u90e8\u7f72\u3002\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Spring Cloud Gateway\u7684\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-yaml\">spring:\n  cloud:\n    gateway:\n      routes:\n        - id: myroute\n          uri: http:\/\/example.com\n          predicates:\n            - Path=\/myroute\/**\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u914d\u7f6e\u5b9a\u4e49\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u8def\u7531\u89c4\u5219\uff0c\u5c06\u4ee5<code>\/myroute\/**<\/code>\u5f00\u5934\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230<code>http:\/\/example.com<\/code>\u3002<\/p>\n<p>\u603b\u4f53\u800c\u8a00\uff0cSpring Cloud Gateway\u4f5c\u4e3a\u4e00\u4e2aAPI\u7f51\u5173\uff0c\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8def\u7531\u548c\u8fc7\u6ee4\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u6784\u5efa\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\u7684\u7edf\u4e00\u5165\u53e3\u548c\u8bf7\u6c42\u5904\u7406\u5c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Spring Cloud\u4e2d\uff0cSpring Cloud Gateway\u662f\u4e00\u4e2a\u5168\u65b0\u7684\u57fa\u4e8eSpring Frame [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[],"class_list":["post-8951","post","type-post","status-publish","format-standard","hentry","category-springcloud"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=8951"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8951\/revisions"}],"predecessor-version":[{"id":16677,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8951\/revisions\/16677"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8951"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}