Ai
1 Star 0 Fork 0

双耳聂/goctl-util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
jsonResult.go 636 Bytes
一键复制 编辑 原始数据 按行查看 历史
双耳 提交于 2024-08-23 23:01 +08:00 . update
package httpResult
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
)
//json 返回内容
type Resp struct {
Code int `json:"coe"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
//ErrJson 返回错误
func ErrJson(w http.ResponseWriter, err error) {
resp := Resp{
Code: http.StatusInternalServerError,
Msg: err.Error(),
Data: nil,
}
httpx.WriteJson(w, http.StatusInternalServerError, resp)
}
//OkJson 返回成功
func OkJson(w http.ResponseWriter, data interface{}) {
resp := Resp{
Code: http.StatusOK,
Msg: "ok",
Data: data,
}
httpx.WriteJson(w, http.StatusOK, resp)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shuanger_nie/goctl-util.git
git@gitee.com:shuanger_nie/goctl-util.git
shuanger_nie
goctl-util
goctl-util
v1.0.2

搜索帮助