We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我知道在 gtoken_resp.go 文件中可以直接修改,有没有不修改库本身文件的方法?
gtoken_resp.go
type Resp struct { Code int `json:"code"` Msg string `json:"message"` Data interface{} `json:"data"` }
The text was updated successfully, but these errors were encountered:
查了一下,实现 LoginAfterFunc 方法,可以重写 response,来实现将 msg 改为 message:
LoginAfterFunc
func LoginAfterFunc(r *ghttp.Request, respData gtoken.Resp) { r.Response.WriteJson(g.Map{ "code": respData.Code, "message": respData.Msg, "data": respData.Data, }) }
Sorry, something went wrong.
@zcool321
但是如果未认证,的 response 如何重新呢?尝试了 AuthAfterFunc,它会使实际响应不执行,直接返回 AuthAfterFunc 的 response:
func AuthAfterFunc(r *ghttp.Request, respData gtoken.Resp) { r.Response.WriteJson(g.Map{ "code": respData.Code, "message": respData.Msg, "data": respData.Data, }) }
{ "code": 0, "data": { "createTime": 1673083704166, "data": "1", "refreshTime": 1673515704166, "userKey": "test", "uuid": "feca4c8130990b85bc2ba63944e666fc" }, "message": "success" }
有没有通过更简单的配置来重新定义 response,比如将 msg 改为 message,有实现此功能吗?
这个库更新太慢了,也不理会issue或pr,建议fork后自己改,或者自己写个
No branches or pull requests
我知道在
gtoken_resp.go
文件中可以直接修改,有没有不修改库本身文件的方法?The text was updated successfully, but these errors were encountered: