response.go 369 B

12345678910111213141516171819202122
  1. package httper
  2. import (
  3. "encoding/json"
  4. "github.com/astaxie/beego/context"
  5. "go.uber.org/zap"
  6. )
  7. func JSON(ctx *context.Context, param interface{}, logID string) {
  8. if ctx == nil {
  9. return
  10. }
  11. ctx.Output.JSON(param, false, false)
  12. if Debug && DebugLog != nil {
  13. data, _ := json.Marshal(param)
  14. DebugLog.Debug(logID, zap.String("response", string(data)))
  15. }
  16. }