(c *gin.Context, msgCode int, msg interface{}, data interface{})
| 33 | } |
| 34 | |
| 35 | func ResponseWithCode(c *gin.Context, msgCode int, msg interface{}, data interface{}) { |
| 36 | if msg == nil { |
| 37 | if val, ok := MsgCodeMap[msgCode]; ok { |
| 38 | msg = val |
| 39 | } else { |
| 40 | msg = MsgCodeMap[-1] |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | c.AbortWithStatusJSON(http.StatusOK, gin.H{ |
| 45 | "code": msgCode, |
| 46 | "message": msg, |
| 47 | "data": data, |
| 48 | }) |
| 49 | } |
no outgoing calls
no test coverage detected