fix: middleware now record real success info

This commit is contained in:
Paul Pan 2022-09-26 17:15:31 +08:00
parent 529b41332c
commit 2ae99e2636
2 changed files with 3 additions and 0 deletions

View File

@ -21,5 +21,6 @@ func Wrap(status Status, body interface{}) interface{} {
} }
func Pong(c *gin.Context, status Status, body interface{}) { func Pong(c *gin.Context, status Status, body interface{}) {
c.Set("err", status)
c.JSON(http.StatusOK, Wrap(status, body)) c.JSON(http.StatusOK, Wrap(status, body))
} }

View File

@ -34,6 +34,8 @@ func (m *Metrics) Handler() gin.HandlerFunc {
if !ok { if !ok {
success = false success = false
err = e.Unknown err = e.Unknown
} else if err != e.Success {
success = false
} }
m.Record(method, url, success, status, err, elapsed) m.Record(method, url, success, status, err, elapsed)