清理冗余written字段
This commit is contained in:
@@ -364,11 +364,9 @@ func proxyDockerAuthWithCache(c *gin.Context) {
|
|||||||
globalCache.SetToken(cacheKey, string(recorder.body), ttl)
|
globalCache.SetToken(cacheKey, string(recorder.body), ttl)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 写入实际响应(如果还没写入)
|
// 6. 写入实际响应
|
||||||
if !recorder.written {
|
c.Writer = recorder.ResponseWriter
|
||||||
c.Writer = recorder.ResponseWriter
|
c.Data(recorder.statusCode, "application/json", recorder.body)
|
||||||
c.Data(recorder.statusCode, "application/json", recorder.body)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResponseRecorder HTTP响应记录器
|
// ResponseRecorder HTTP响应记录器
|
||||||
@@ -376,7 +374,6 @@ type ResponseRecorder struct {
|
|||||||
gin.ResponseWriter
|
gin.ResponseWriter
|
||||||
statusCode int
|
statusCode int
|
||||||
body []byte
|
body []byte
|
||||||
written bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ResponseRecorder) WriteHeader(code int) {
|
func (r *ResponseRecorder) WriteHeader(code int) {
|
||||||
@@ -385,7 +382,6 @@ func (r *ResponseRecorder) WriteHeader(code int) {
|
|||||||
|
|
||||||
func (r *ResponseRecorder) Write(data []byte) (int, error) {
|
func (r *ResponseRecorder) Write(data []byte) (int, error) {
|
||||||
r.body = append(r.body, data...)
|
r.body = append(r.body, data...)
|
||||||
r.written = true
|
|
||||||
return len(data), nil
|
return len(data), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user