We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 15722ca commit 57496f5Copy full SHA for 57496f5
framework/components/fake/record.go
@@ -6,10 +6,12 @@ import (
6
"github.com/gin-gonic/gin"
7
"io/ioutil"
8
"net/http"
9
+ "sync"
10
)
11
12
var (
- R = NewRecords()
13
+ R = NewRecords()
14
+ mu sync.Mutex
15
16
17
// Record is a request and response data
@@ -78,6 +80,8 @@ func recordMiddleware() gin.HandlerFunc {
78
80
// Capture response data
79
81
resBody := customWriter.body.String()
82
status := c.Writer.Status()
83
+ mu.Lock()
84
+ defer mu.Unlock()
85
if R.Data[c.Request.URL.Path] == nil {
86
R.Data[c.Request.URL.Path] = make([]*Record, 0)
87
}
0 commit comments