{"id":280072,"date":"2021-01-12T08:27:32","date_gmt":"2021-01-12T00:27:32","guid":{"rendered":"http:\/\/4563.org\/?p=280072"},"modified":"2021-01-12T08:27:32","modified_gmt":"2021-01-12T00:27:32","slug":"%e6%9c%80%e8%bf%91%e7%bc%96%e5%86%99%e4%ba%86%e4%b8%80%e4%b8%aa%e7%bb%99-gin-%e6%a1%86%e6%9e%b6%e5%ae%9e%e7%8e%b0%e6%b3%a8%e8%a7%a3%e8%b7%af%e7%94%b1%e7%9a%84%e5%b7%a5%e5%85%b7%e4%b8%aa%e4%ba%ba","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=280072","title":{"rendered":"\u6700\u8fd1\u7f16\u5199\u4e86\u4e00\u4e2a\u7ed9 gin \u6846\u67b6\u5b9e\u73b0\u6ce8\u89e3\u8def\u7531\u7684\u5de5\u5177,\u4e2a\u4eba\u89c9\u5f97\u633a\u6709\u5b9e\u9645\u610f\u4e49"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6700\u8fd1\u7f16\u5199\u4e86\u4e00\u4e2a\u7ed9 gin \u6846\u67b6\u5b9e\u73b0\u6ce8\u89e3\u8def\u7531\u7684\u5de5\u5177,\u4e2a\u4eba\u89c9\u5f97\u633a\u6709\u5b9e\u9645\u610f\u4e49               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : usralpha <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f4d\u7f6e github.com\/1-st\/gin-annotation \u5b9e\u73b0\u7684\u6548\u679c\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre><code> \/* Hello a simple controller [  method:GET,  groups:\/api,  path:\/hello-world,  need:auth ] *\/ func HelloWorld(ctx *gin.Context) {  ctx.JSON( http.StatusOK, map[string]string{   \"msg\": \"hello, world\",  }) } <\/code><\/pre>\n<p>\u601d\u8def\uff1a\u8bfb\u53d6 Go \u6e90\u4ee3\u7801\u7684 AST \u6587\u4ef6\uff0c\u7136\u540e\u751f\u6210\u4e00\u4e2a route.entry.go \u8def\u7531\u6587\u4ef6,\u50cf\u8fd9\u6837:<\/p>\n<pre><code>import (  \"gin-annotation\/_example\/simple\/controller\"  \"gin-annotation\/_example\/simple\/middleware\"  \"github.com\/gin-gonic\/gin\" )  func Route(e *gin.Engine) {  api := e.Group(\"\/api\", middleware.Log)  {   v1 := api.Group(\"\/v1\")   {    v1.GET(\"\/hello-world\", middleware.Auth, controller.HelloWorld)   }  } } <\/code><\/pre>\n<p>\u5982\u679c\u89c9\u5f97\u6709\u7528 \/\u6709\u8da3\u8bf7 star,\u8c22\u8c22\uff01<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4938666\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zoharSoul <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u633a\u6709\u610f\u601d\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938667\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wellsc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938668\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : usralpha <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zoharSoul \u8c22\u8c22\uff01\u5934\u4e00\u6b21\u5f97\u5230\u652f\u6301                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938669\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : usralpha <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @wellsc \u8c22\u8c22\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938670\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kidlj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Go \u652f\u6301\u88c5\u9970\u5668\u5c31\u597d\u4e86\uff0c\u4e0d\u8fc7\u6211\u89c9\u5f97\u5e0c\u671b\u4e0d\u5927                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938671\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gowk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5988\u8036\uff0c\u8fd9\u6ce2\u64cd\u4f5c\u592a\u9a9a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938672\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ansi395958 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4938673\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : TypeErrorNone <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ca1\u5565\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u7f16\u5199\u4e86\u4e00\u4e2a\u7ed9 gin \u6846\u67b6\u5b9e\u73b0&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/280072"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=280072"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/280072\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=280072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=280072"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=280072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}