git clone https://github.com/edisonlz/Gin_API_Framework.git 代码需要clone到 $GOPATH/src 下 cd Gin_API_Framework/ && godep restore godep restore 可能会失败可以将vendor下代码复制到 $GOPATH/src 下 ed@localhost src$ ls Gin_
mainapp docs .gitignore Makefile README.md config.yaml go.mod go.sum main.goBreadcrumbs gin-api / .gitignore Latest commit iaping init 7b18506· Apr 28, 2024 HistoryHistory File metadata and controls Code Blame 10 lines (10 loc) · 86 Bytes Raw .idea/ .DS_Store .idea .vscode bin...
package logger import ( "bytes" "encoding/json" "fmt" "github.com/gin-gonic/gin" "go-gin-api/app/config" "go-gin-api/app/util" "log" "os" ) type bodyLogWriter struct { gin.ResponseWriter body *bytes.Buffer } func (w bodyLogWriter) Write(b []byte) (int, error) { w.body.Wri...
就到这吧。 API 源码地址 github.com/xinliangnote Service 源码地址 github.com/xinliangnote go-gin-api 系列文章 1. 使用 go modules 初始化项目 2. 规划项目目录和参数验证 3. 路由中间件 - 日志记录 4. 路由中间件 - 捕获异常 5. 路由中间件 - Jaeger 链路追踪(理论篇) ...
dependabot/go_modules/github.com/prometheus/client_golang-1.11.1 v1.2.7 v1.2.6 v1.2.5 v1.2.4 v1.2.3 v1.2.2 v1.2.1 v1.2.0 v2.0.0 v1.0 克隆/下载 克隆/下载 HTTPSSSHSVNSVN+SSH下载ZIP 该操作需登录 Gitee 帐号,请先登录后再操作。
githubConfigRouter(router) for _, route := range githubAPI { path, values := exampleFromPath(route.path) w := PerformRequest(router, route.method, path) // TEST assert.Contains(t, w.Body.String(), "\"status\":\"good\"") for _, value := range values { str := fmt....
packageloggerimport("bytes""encoding/json""fmt""github.com/gin-gonic/gin""go-gin-api/app/config""go-gin-api/app/util""log""os")type bodyLogWriter struct{gin.ResponseWriter body*bytes.Buffer}func(w bodyLogWriter)Write(b[]byte)(int,error){w.body.Write(b)returnw.ResponseWriter.Write(b)...
复制 {"code":-1,"msg":"Key: 'ProductAdd.Name' Error:Field validation for 'Name' failed on the 'NameValid' tag","data":null} OK,上面两个验证都生效了! 源码地址 https://github.com/xinliangnote/go-gin-api go-gin-api 系列文章
"github.com/gin-gonic/gin" . "GinLearn/GinLearn/models" ) //Api调用的页面 func GetApiHtml(c *gin.Context){ c.HTML(http.StatusOK,"api.html",gin.H{ "title":"Go-Gin Api调用页面", }) } //Json格式的数据 func GetJsonData(c *gin.Context) { //得到请求的参数 search:=c.PostForm...
[系列] - go-gin-api 路由中间件 - 日志记录(三),概述首先同步下项目概况:上篇文章分享了,规划项目目录和参数验证,其中参数验证使用的是validator.v8版本,现已更新到validator.v9版本,最新代码查看github即可。这篇文章咱们分享:路由中间件-日志记录。日志是特别重