Use c.ResponseOk() for all places.

This commit is contained in:
Yang Luo
2021-08-08 16:00:19 +08:00
parent a5783598ff
commit 9feefc31f9
5 changed files with 24 additions and 27 deletions

View File

@ -55,6 +55,20 @@ func InitHttpClient() {
//println("Response status: %s", resp.Status)
}
// ResponseOk ...
func (c *ApiController) ResponseOk(data ...interface{}) {
resp := Response{Status: "ok"}
switch len(data) {
case 2:
resp.Data2 = data[1]
fallthrough
case 1:
resp.Data = data[0]
}
c.Data["json"] = resp
c.ServeJSON()
}
// ResponseError ...
func (c *ApiController) ResponseError(error string, data ...interface{}) {
resp := Response{Status: "error", Msg: error}