Skip to content
New issue

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

不规范的接口定义 #8

Open
fdkevin0 opened this issue May 26, 2022 · 1 comment
Open

不规范的接口定义 #8

fdkevin0 opened this issue May 26, 2022 · 1 comment
Assignees

Comments

@fdkevin0
Copy link
Contributor

以前的接口定义中已以rpc接口返回值作为json返回值中data,error中放置返回体中code/error、msg,使用中间件将code/error、msg写入返回体。
但是实际上这个形式是不可取的:

  • 请求返回值与文档不符合
  • grpc请求err会在传输时抛弃返回体,无法做到同时输出err与返回体
    根据以上原因,接口定义将会改为更标准形式,rpc err将只承载内部错误,而非返回体错误
@fdkevin0 fdkevin0 self-assigned this May 27, 2022
@fdkevin0
Copy link
Contributor Author

fdkevin0 commented Jul 8, 2022

规定下http status和error两个错误码的使用:
http status 使用于返回体结构被破坏情况,如鉴权错误、参数错误等
返回体结构正常时,使用StatusOK 200+状态码标记

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant