diff --git a/service/restful/wrap/report.go b/service/restful/wrap/report.go new file mode 100644 index 0000000..a2a3681 --- /dev/null +++ b/service/restful/wrap/report.go @@ -0,0 +1,10 @@ +package wrap + +import ( + "time" + + "github.com/gin-gonic/gin" + "github.com/lworkltd/kits/service/restful/code" +) + +var Report func(err code.Error, ctx *gin.Context, status int, since time.Time) diff --git a/service/restful/wrap/wrapper.go b/service/restful/wrap/wrapper.go index e63563b..f2615eb 100644 --- a/service/restful/wrap/wrapper.go +++ b/service/restful/wrap/wrapper.go @@ -254,6 +254,10 @@ func (wrapper *Wrapper) Wrap(f WrappedFunc, registPath string) gin.HandlerFunc { httpCtx.JSON(http.StatusOK, resp) } + if Report != nil { + Report(cerr, httpCtx, http.StatusOK, since) + } + if cerr != nil { l.WithFields(logrus.Fields{ "message": cerr.Message(),