Improve API error handling.

This commit is contained in:
Yang Luo
2021-03-28 00:48:34 +08:00
parent 6c2c5be33d
commit d6715c7601
18 changed files with 54 additions and 69 deletions

View File

@ -32,3 +32,11 @@ func (c *ApiController) GetSessionUser() string {
func (c *ApiController) SetSessionUser(user string) {
c.SetSession("username", user)
}
func wrapActionResponse(affected bool) *Response {
if affected {
return &Response{Status: "ok", Msg: "", Data: "affected"}
} else {
return &Response{Status: "ok", Msg: "", Data: "unaffected"}
}
}