### [gin-dump](https://github.com/tpkeeper/gin-dump)
##### 项目地址[https://github.com/tpkeeper/gin-dump](https://github.com/tpkeeper/gin-dump)
* gin的middleware
* 可以输出出req ,res的header和body内容,方便观察请求和相应结果
##### 使用
```
package main
import (
"fmt"
"time"
"github.com/gin-gonic/gin"
"github.com/tpkeeper/gin-dump"
)
func main() {
router := gin.Default()
router.Use(gindump.Dump(func(dumpStr string) {
fmt.Println(dumpStr)
}))
//...
router.Run()
}
```
##### 效果
```
=== RUN TestMIMEPOSTFORM
[GIN-dump]:
Request-Header:
{
"Content-Type": [
"application/x-www-form-urlencoded"
]
}
Request-Body:
{
"bar": [
"baz"
],
"foo": [
"bar",
"bar2"
]
}
Response-Header:
{
"Content-Type": [
"application/json; charset=utf-8"
]
}
Response-Body:
{
"data": {
"addr": "tpkeeper@qq.com",
"name": "jfise"
},
"ok": true
}
```
有疑问加站长微信联系(非本文作者)