{"id":46,"date":"2021-01-15T18:29:18","date_gmt":"2021-01-15T10:29:18","guid":{"rendered":"http:\/\/wordpress.rslly.top\/?p=46"},"modified":"2021-01-15T18:29:18","modified_gmt":"2021-01-15T10:29:18","slug":"%e5%ae%87%e5%ae%99%e6%9c%80%e5%bf%ab%e4%b9%8bgo-web%e6%a1%86%e6%9e%b6-iris","status":"publish","type":"post","link":"https:\/\/wordpress.rslly.top\/index.php\/2021\/01\/15\/%e5%ae%87%e5%ae%99%e6%9c%80%e5%bf%ab%e4%b9%8bgo-web%e6%a1%86%e6%9e%b6-iris\/","title":{"rendered":"\u5b87\u5b99\u6700\u5feb\u4e4bgo web\u6846\u67b6\u2014\u2014iris"},"content":{"rendered":"\n<p>\u968f\u98ce<\/p>\n\n\n\n<p>\u6628\u5929\u5174\u81f4\u5927\u53d1\u5199\u4e86\u4e00\u7bc7go\u8bed\u8a00\u7684\u6587\u7ae0\uff0c\u770b\u5230\u4e0d\u5c11\u670b\u53cb\u5bf9go\u8bed\u8a00\u8fd8\u662f\u5f88\u611f\u5174\u8da3\u7684\u3002\u4eca\u5929\u5174\u81f4\u5927\u53d1\uff0c\u51b3\u5b9a\u518d\u5199\u4e00\u7bc7\u5173\u4e8ego web\u5f00\u53d1\u7684\u6587\u7ae0\u3002\u4eca\u5929\u6211\u60f3\u4ecb\u7ecd\u7684\u662f\u5b87\u5b99\u6700\u5feb\u4e4bgo web\u6846\u67b6\u2014\u2014iris\u3002\u662f\u4e0d\u662f\u6709\u70b9\u5938\u5f20\uff1f\u6211\u672c\u4eba\u89c9\u5f97\u786e\u5b9e\u6709\u70b9\u5938\u5f20\uff0c\u4e0d\u8fc7iris\u6846\u67b6\u7684\u5b98\u65b9GitHub\u6587\u6863\u662f\u8fd9\u4e48\u5199\u7684\uff0c\u6211\u4e5f\u5c31\u4e0d\u597d\u53cd\u9a73\u4e86\uff0c\u5b9e\u9645\u4e0airis\u6846\u67b6\u7684\u6027\u80fd\u786e\u5b9e\u6bd4spring boot\u9ad8\u51fa\u5f88\u591a\uff0c\u800c\u4e14\u80fd\u6ee1\u8db3\u6811\u8393\u6d3e\u7b49\u8bbe\u5907\u9700\u6c42\uff0c\u8f7b\u91cf\u7b80\u6d01\uff0c\u8fd9\u5927\u6982\u4e5f\u662fgo\u8bed\u8a00\u7684\u7279\u70b9\u5427\u3002<\/p>\n\n\n\n<p>\u505a\u8fc7\u540e\u7aef\u7684\u5404\u4f4d\u670b\u53cb\u80af\u5b9a\u90fd\u77e5\u9053\uff0c\u91cd\u9020\u8f6e\u5b50\u662f\u4e00\u4ef6\u975e\u5e38\u9ebb\u70e6\u7684\u4e8b\u3002\u6211\u4eec\u56fa\u7136\u53ef\u4ee5\u4ecesocket\u5f00\u59cb\u5199\u8d77\uff0c\u4f46\u662f\u8fd9\u6837\u7684\u5f00\u53d1\u6548\u7387\u80af\u5b9a\u662f\u3002\u3002\u3002\uff08\u4e0d\u7528\u591a\u8bf4\u3002\u3002\uff09\u5176\u5b9ejava\u771f\u6b63\u5389\u5bb3\u7684\u4e5f\u8bb8\u4e0d\u662f\u8bed\u8a00\u672c\u8eab\uff0c\u800c\u662f\u9644\u7740\u5728java\u4e0a\u7684\u4f17\u591a\u6846\u67b6\uff0c\u4f8b\u5982spring\u3002\u6709\u4e86\u8fd9\u4e9b\u811a\u624b\u67b6\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u7ad9\u5728\u524d\u4eba\u7684\u80a9\u8180\u4e0a\u8d70\u5f97\u66f4\u8fdc\u3002<\/p>\n\n\n\n<p>iris\u7684\u5b89\u88c5\u5f88\u5bb9\u6613\uff0c\u53ea\u9700\u8981go get -u github.com\/kataras\/iris\uff0c\u5f53\u7136\u524d\u63d0\u6761\u4ef6\u662f\u5b89\u88c5\u4e86go\u7f16\u8bd1\u5668\uff0c\u5982\u679c\u4e0d\u61c2\u5b89\u88c5\u800c\u5bf9go\u8bed\u8a00\u611f\u5174\u8da3\u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u79c1\u4fe1\u521b\u4e07\u8054\u516c\u4f17\u53f7\u54e6\u3002<\/p>\n\n\n\n<p>\u5148\u6765\u4e00\u6bb5iris\u6846\u67b6\u4f7f\u7528\u7684\u7b80\u5355demo<\/p>\n\n\n\n<p>package main<\/p>\n\n\n\n<p>import (<br>&#8220;github.com\/kataras\/iris&#8221;<br>&#8220;github.com\/kataras\/iris\/context&#8221;<br>)<\/p>\n\n\n\n<p>func main() {<br>app := iris.New()<br>app.Get(&#8220;\/&#8221;, func(ctx context.Context){<\/p>\n\n\n\n<p>ctx.HTML(&#8220;&lt;h1>Welcome&lt;\/h1>&#8221;)<\/p>\n\n\n\n<p>})<br>app.Run(iris.Addr(&#8220;:8080&#8221;))<br>}<\/p>\n\n\n\n<p>\u5c06\u5176\u590d\u5236\u540e\u4fdd\u5b58\u5230\u8bb0\u4e8b\u672c\uff0c\u7136\u540e\u547d\u540d\u4e3amain.go\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u3002go build main.go,\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165127.0.0.1:8080\/\u5373\u53ef\u4ee5\u770b\u5230welcome\u663e\u793a\u5728\u6d4f\u89c8\u5668\u4e0a\u3002\u662f\u4e0d\u662f\u611f\u89c9\u5f88\u7b80\u5355\uff0c\u5f88\u60f3\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u90a3\u5c31\u8d76\u5feb\u52a8\u624b\u8bd5\u8bd5\u5427\u3002<\/p>\n\n\n\n<p>\u4e8b\u5b9e\u4e0airis\u4e3a\u6211\u4eec\u5305\u88c5\u4e86\u8def\u7531\u5904\u7406\u4ee5\u53ca\u5b8c\u6574\u7684mvc\u6846\u67b6\u652f\u6301\uff0c\u4ee5\u53ca\u4ee4\u4eba\u5174\u594b\u7684\u4e2d\u95f4\u4ef6\u5904\u7406\uff0c\u8003\u8bd5\u8981\u7d27\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u804a\u5230\u8fd9\u5427\uff0c\u4e0b\u671f\u518d\u89c1\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"344\" height=\"344\" src=\"https:\/\/wordpress.rslly.top\/wp-content\/uploads\/2020\/10\/\u5fae\u4fe1\u56fe\u7247_20201007185559.jpg\" alt=\"\" class=\"wp-image-37\" srcset=\"https:\/\/wordpress.rslly.top\/wp-content\/uploads\/2020\/10\/\u5fae\u4fe1\u56fe\u7247_20201007185559.jpg 344w, https:\/\/wordpress.rslly.top\/wp-content\/uploads\/2020\/10\/\u5fae\u4fe1\u56fe\u7247_20201007185559-300x300.jpg 300w, https:\/\/wordpress.rslly.top\/wp-content\/uploads\/2020\/10\/\u5fae\u4fe1\u56fe\u7247_20201007185559-150x150.jpg 150w\" sizes=\"auto, (max-width: 344px) 100vw, 344px\" \/><\/figure>\n\n\n<div id='contact-form-46'>\n<form action='https:\/\/wordpress.rslly.top\/index.php\/2021\/01\/15\/%e5%ae%87%e5%ae%99%e6%9c%80%e5%bf%ab%e4%b9%8bgo-web%e6%a1%86%e6%9e%b6-iris\/#contact-form-46' method='post' class='contact-form commentsblock wp-block-jetpack-contact-form'>\n\n\n<div class='grunion-field-wrap grunion-field-name-wrap'  >\n<label\n\t\t\t\tfor='g46'\n\t\t\t\tclass='grunion-field-label name'\n\t\t\t\t>\u540d\u79f0<span>\uff08\u5fc5\u586b\uff09<\/span><\/label>\n<input\n\t\t\t\t\ttype='text'\n\t\t\t\t\tname='g46'\n\t\t\t\t\tid='g46'\n\t\t\t\t\tvalue=''\n\t\t\t\t\tclass='name' \n\t\t\t\t\trequired aria-required='true'\n\t\t\t\t\/>\n\t<\/div>\n\n\n\n<div class='grunion-field-wrap grunion-field-email-wrap'  >\n<label\n\t\t\t\tfor='g46-1'\n\t\t\t\tclass='grunion-field-label email'\n\t\t\t\t>\u7535\u5b50\u90ae\u7bb1<span>\uff08\u5fc5\u586b\uff09<\/span><\/label>\n<input\n\t\t\t\t\ttype='email'\n\t\t\t\t\tname='g46-1'\n\t\t\t\t\tid='g46-1'\n\t\t\t\t\tvalue=''\n\t\t\t\t\tclass='email' \n\t\t\t\t\trequired aria-required='true'\n\t\t\t\t\/>\n\t<\/div>\n\n\n\n<div class='grunion-field-wrap grunion-field-textarea-wrap'  >\n<label\n\t\t\t\tfor='contact-form-comment-g46-2'\n\t\t\t\tclass='grunion-field-label textarea'\n\t\t\t\t>\u90ae\u4ef6<\/label>\n<textarea\n\t\t                name='g46-2'\n\t\t                id='contact-form-comment-g46-2'\n\t\t                rows='20' class='textarea'  ><\/textarea>\n\t<\/div>\n\n\n<div class=\"wp-block-jetpack-button\"><button class=\"wp-block-button__link\" style=\"\" data-id-attr=\"placeholder\" type=\"submit\">\u8054\u7cfb\u6211\u4eec<\/button><\/div>\n\t\t<input type='hidden' name='contact-form-id' value='46' \/>\n\t\t<input type='hidden' name='action' value='grunion-contact-form' \/>\n\t\t<input type='hidden' name='contact-form-hash' value='388dfa87c1ee5969644a192f6c2d8cbd593444ab' \/>\n<\/form>\n<\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u98ce \u6628\u5929\u5174\u81f4\u5927\u53d1\u5199\u4e86\u4e00\u7bc7go\u8bed\u8a00\u7684\u6587\u7ae0\uff0c\u770b\u5230\u4e0d\u5c11\u670b\u53cb\u5bf9go\u8bed\u8a00\u8fd8\u662f\u5f88\u611f\u5174\u8da3\u7684\u3002\u4eca\u5929\u5174\u81f4\u5927\u53d1\uff0c\u51b3\u5b9a\u518d\u5199\u4e00\u7bc7\u5173\u4e8e &hellip; <a href=\"https:\/\/wordpress.rslly.top\/index.php\/2021\/01\/15\/%e5%ae%87%e5%ae%99%e6%9c%80%e5%bf%ab%e4%b9%8bgo-web%e6%a1%86%e6%9e%b6-iris\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5b87\u5b99\u6700\u5feb\u4e4bgo web\u6846\u67b6\u2014\u2014iris<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"spay_email":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":2,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/posts\/46\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.rslly.top\/index.php\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}